* [PATCH] vrf: Fix use-after-free in vrf_xmit
@ 2017-03-06 16:53 David Ahern
2017-03-09 7:10 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: David Ahern @ 2017-03-06 16:53 UTC (permalink / raw)
To: netdev; +Cc: David Ahern
KASAN detected a use-after-free:
[ 269.467067] BUG: KASAN: use-after-free in vrf_xmit+0x7f1/0x827 [vrf] at addr ffff8800350a21c0
[ 269.467067] Read of size 4 by task ssh/1879
[ 269.467067] CPU: 1 PID: 1879 Comm: ssh Not tainted 4.10.0+ #249
[ 269.467067] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.7.5-20140531_083030-gandalf 04/01/2014
[ 269.467067] Call Trace:
[ 269.467067] dump_stack+0x81/0xb6
[ 269.467067] kasan_object_err+0x21/0x78
[ 269.467067] kasan_report+0x2f7/0x450
[ 269.467067] ? vrf_xmit+0x7f1/0x827 [vrf]
[ 269.467067] ? ip_output+0xa4/0xdb
[ 269.467067] __asan_load4+0x6b/0x6d
[ 269.467067] vrf_xmit+0x7f1/0x827 [vrf]
...
Which corresponds to the skb access after xmit handling. Fix by saving
skb->len and using the saved value to update stats.
Fixes: 193125dbd8eb2 ("net: Introduce VRF device driver")
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
drivers/net/vrf.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 22379da63400..fea687f35b5a 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -340,6 +340,7 @@ static netdev_tx_t is_ip_tx_frame(struct sk_buff *skb, struct net_device *dev)
static netdev_tx_t vrf_xmit(struct sk_buff *skb, struct net_device *dev)
{
+ int len = skb->len;
netdev_tx_t ret = is_ip_tx_frame(skb, dev);
if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN)) {
@@ -347,7 +348,7 @@ static netdev_tx_t vrf_xmit(struct sk_buff *skb, struct net_device *dev)
u64_stats_update_begin(&dstats->syncp);
dstats->tx_pkts++;
- dstats->tx_bytes += skb->len;
+ dstats->tx_bytes += len;
u64_stats_update_end(&dstats->syncp);
} else {
this_cpu_inc(dev->dstats->tx_drps);
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] vrf: Fix use-after-free in vrf_xmit
2017-03-06 16:53 [PATCH] vrf: Fix use-after-free in vrf_xmit David Ahern
@ 2017-03-09 7:10 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-03-09 7:10 UTC (permalink / raw)
To: dsa; +Cc: netdev
From: David Ahern <dsa@cumulusnetworks.com>
Date: Mon, 6 Mar 2017 08:53:04 -0800
> KASAN detected a use-after-free:
>
> [ 269.467067] BUG: KASAN: use-after-free in vrf_xmit+0x7f1/0x827 [vrf] at addr ffff8800350a21c0
> [ 269.467067] Read of size 4 by task ssh/1879
> [ 269.467067] CPU: 1 PID: 1879 Comm: ssh Not tainted 4.10.0+ #249
> [ 269.467067] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.7.5-20140531_083030-gandalf 04/01/2014
> [ 269.467067] Call Trace:
> [ 269.467067] dump_stack+0x81/0xb6
> [ 269.467067] kasan_object_err+0x21/0x78
> [ 269.467067] kasan_report+0x2f7/0x450
> [ 269.467067] ? vrf_xmit+0x7f1/0x827 [vrf]
> [ 269.467067] ? ip_output+0xa4/0xdb
> [ 269.467067] __asan_load4+0x6b/0x6d
> [ 269.467067] vrf_xmit+0x7f1/0x827 [vrf]
> ...
>
> Which corresponds to the skb access after xmit handling. Fix by saving
> skb->len and using the saved value to update stats.
>
> Fixes: 193125dbd8eb2 ("net: Introduce VRF device driver")
> Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Applied and queued up for -stable, thanks David.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-09 7:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-06 16:53 [PATCH] vrf: Fix use-after-free in vrf_xmit David Ahern
2017-03-09 7:10 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).