Skip to content

Commit e671f1c

Browse files
David Aherngregkh
David Ahern
authored andcommitted
vrf: Fix use-after-free in vrf_xmit
[ Upstream commit f7887d4 ] 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+ raspberrypi#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: 193125d ("net: Introduce VRF device driver") Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d0ebde9 commit e671f1c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/vrf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,14 +345,15 @@ static netdev_tx_t is_ip_tx_frame(struct sk_buff *skb, struct net_device *dev)
345345

346346
static netdev_tx_t vrf_xmit(struct sk_buff *skb, struct net_device *dev)
347347
{
348+
int len = skb->len;
348349
netdev_tx_t ret = is_ip_tx_frame(skb, dev);
349350

350351
if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN)) {
351352
struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats);
352353

353354
u64_stats_update_begin(&dstats->syncp);
354355
dstats->tx_pkts++;
355-
dstats->tx_bytes += skb->len;
356+
dstats->tx_bytes += len;
356357
u64_stats_update_end(&dstats->syncp);
357358
} else {
358359
this_cpu_inc(dev->dstats->tx_drps);

0 commit comments

Comments
 (0)