KASAN: use-after-free Read in pfifo_fast_enqueue

33 views
Skip to first unread message

syzbot

unread,
Jan 16, 2018, 1:29:02 PM1/16/18
to da...@davemloft.net, j...@mojatatu.com, ji...@resnulli.us, linux-...@vger.kernel.org, net...@vger.kernel.org, syzkall...@googlegroups.com, xiyou.w...@gmail.com
Hello,

syzkaller hit the following crash on
ce3c209f6733e2cff9335bb1b2ac847fa823410a
git://git.cmpxchg.org/linux-mmots.git/master
compiler: gcc (GCC) 7.1.1 20170620
.config is attached
Raw console output is attached.
Unfortunately, I don't have any reproducer for this bug yet.


IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+ed43b6...@syzkaller.appspotmail.com
It will help syzbot understand when the bug is fixed. See footer for
details.
If you forward the report, please keep this part and the footer.

==================================================================
BUG: KASAN: use-after-free in qdisc_pkt_len include/net/sch_generic.h:577
[inline]
BUG: KASAN: use-after-free in qdisc_qstats_cpu_backlog_inc
include/net/sch_generic.h:679 [inline]
BUG: KASAN: use-after-free in pfifo_fast_enqueue+0x398/0x420
net/sched/sch_generic.c:639
Read of size 4 at addr ffff8801bc753be8 by task syz-executor6/4865

CPU: 1 PID: 4865 Comm: syz-executor6 Not tainted 4.15.0-rc7-mm1+ #56
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
<IRQ>
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x194/0x257 lib/dump_stack.c:53
print_address_description+0x73/0x250 mm/kasan/report.c:256
kasan_report_error mm/kasan/report.c:354 [inline]
kasan_report+0x23b/0x360 mm/kasan/report.c:412
__asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:432
qdisc_pkt_len include/net/sch_generic.h:577 [inline]
qdisc_qstats_cpu_backlog_inc include/net/sch_generic.h:679 [inline]
pfifo_fast_enqueue+0x398/0x420 net/sched/sch_generic.c:639
__dev_xmit_skb net/core/dev.c:3199 [inline]
__dev_queue_xmit+0xb54/0x2b50 net/core/dev.c:3501
dev_queue_xmit+0x17/0x20 net/core/dev.c:3566
neigh_resolve_output+0x5e2/0xa00 net/core/neighbour.c:1350
neigh_output include/net/neighbour.h:482 [inline]
ip6_finish_output2+0xb4a/0x23a0 net/ipv6/ip6_output.c:120
ip6_finish_output+0x698/0xaf0 net/ipv6/ip6_output.c:154
NF_HOOK_COND include/linux/netfilter.h:277 [inline]
ip6_output+0x1eb/0x840 net/ipv6/ip6_output.c:171
dst_output include/net/dst.h:443 [inline]
NF_HOOK include/linux/netfilter.h:288 [inline]
mld_sendpack+0x739/0xe70 net/ipv6/mcast.c:1660
mld_send_cr net/ipv6/mcast.c:1956 [inline]
mld_ifc_timer_expire+0x3d9/0x770 net/ipv6/mcast.c:2453
call_timer_fn+0x228/0x820 kernel/time/timer.c:1318
expire_timers kernel/time/timer.c:1355 [inline]
__run_timers+0x7ee/0xb70 kernel/time/timer.c:1658
run_timer_softirq+0x4c/0x70 kernel/time/timer.c:1684
__do_softirq+0x2d7/0xb85 kernel/softirq.c:285
invoke_softirq kernel/softirq.c:365 [inline]
irq_exit+0x1cc/0x200 kernel/softirq.c:405
exiting_irq arch/x86/include/asm/apic.h:540 [inline]
smp_apic_timer_interrupt+0x16b/0x700 arch/x86/kernel/apic/apic.c:1052
apic_timer_interrupt+0xa9/0xb0 arch/x86/entry/entry_64.S:926
</IRQ>
RIP: 0010:clear_page_erms+0x7/0x10 arch/x86/lib/clear_page_64.S:49
RSP: 0000:ffff8801a76bf6b0 EFLAGS: 00010246 ORIG_RAX: ffffffffffffff11
RAX: 0000000000000000 RBX: dffffc0000000000 RCX: 00000000000007c0
RDX: ffff8801d6d6e200 RSI: 0000160000000000 RDI: ffff88019e85a840
RBP: ffff8801a76bf700 R08: 000000000002f8d0 R09: 0000000000000000
R10: ffffffffffffffe8 R11: 0000000000000000 R12: ffffea00067a0000
R13: 000000000000003a R14: 000000000000001d R15: 000000000000005a
__do_huge_pmd_anonymous_page mm/huge_memory.c:570 [inline]
do_huge_pmd_anonymous_page+0x599/0x1b00 mm/huge_memory.c:728
create_huge_pmd mm/memory.c:3856 [inline]
__handle_mm_fault+0x1a0c/0x3ce0 mm/memory.c:4060
handle_mm_fault+0x38f/0x930 mm/memory.c:4126
__do_page_fault+0x5c9/0xc90 arch/x86/mm/fault.c:1429
do_page_fault+0xee/0x720 arch/x86/mm/fault.c:1504
page_fault+0x4c/0x60 arch/x86/entry/entry_64.S:1249
RIP: 0033:0x405a59
RSP: 002b:0000000000a2f900 EFLAGS: 00010246
RAX: 000000002001d000 RBX: 000000000071bea0 RCX: 0000000000000002
RDX: da87a31dca9dcacc RSI: 0000000000000000 RDI: 0000000002261848
RBP: 0000000000000006 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000a2f900 R11: 0000000000000206 R12: fffffffffffffffe
R13: ffffffffffffffff R14: 0000000000000001 R15: 0000000000000001

Allocated by task 4865:
save_stack+0x43/0xd0 mm/kasan/kasan.c:447
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:552
kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:489
kmem_cache_alloc_node+0x144/0x760 mm/slab.c:3631
__alloc_skb+0xf1/0x780 net/core/skbuff.c:193
alloc_skb include/linux/skbuff.h:983 [inline]
alloc_skb_with_frags+0x10d/0x750 net/core/skbuff.c:5151
sock_alloc_send_pskb+0x787/0x9b0 net/core/sock.c:2088
sock_alloc_send_skb+0x32/0x40 net/core/sock.c:2105
mld_newpack+0x39a/0xaf0 net/ipv6/mcast.c:1585
add_grhead.isra.24+0x29f/0x380 net/ipv6/mcast.c:1691
add_grec+0xb89/0x10c0 net/ipv6/mcast.c:1822
mld_send_cr net/ipv6/mcast.c:1948 [inline]
mld_ifc_timer_expire+0x364/0x770 net/ipv6/mcast.c:2453
call_timer_fn+0x228/0x820 kernel/time/timer.c:1318
expire_timers kernel/time/timer.c:1355 [inline]
__run_timers+0x7ee/0xb70 kernel/time/timer.c:1658
run_timer_softirq+0x4c/0x70 kernel/time/timer.c:1684
__do_softirq+0x2d7/0xb85 kernel/softirq.c:285

Freed by task 23:
save_stack+0x43/0xd0 mm/kasan/kasan.c:447
set_track mm/kasan/kasan.c:459 [inline]
__kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:520
kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:527
__cache_free mm/slab.c:3485 [inline]
kmem_cache_free+0x86/0x2b0 mm/slab.c:3743
kfree_skbmem+0x1a1/0x1d0 net/core/skbuff.c:582
__kfree_skb net/core/skbuff.c:642 [inline]
kfree_skb+0x165/0x4c0 net/core/skbuff.c:659
ip_tunnel_xmit+0x709/0x3650 net/ipv4/ip_tunnel.c:796
__gre_xmit+0x546/0x8b0 net/ipv4/ip_gre.c:461
erspan_xmit+0x7eb/0x2430 net/ipv4/ip_gre.c:744
__netdev_start_xmit include/linux/netdevice.h:4046 [inline]
netdev_start_xmit include/linux/netdevice.h:4055 [inline]
xmit_one net/core/dev.c:3020 [inline]
dev_hard_start_xmit+0x24e/0xac0 net/core/dev.c:3036
sch_direct_xmit+0x40d/0x1140 net/sched/sch_generic.c:327
qdisc_restart net/sched/sch_generic.c:393 [inline]
__qdisc_run+0x57d/0x19c0 net/sched/sch_generic.c:401
__dev_xmit_skb net/core/dev.c:3200 [inline]
__dev_queue_xmit+0xb62/0x2b50 net/core/dev.c:3501
dev_queue_xmit+0x17/0x20 net/core/dev.c:3566
neigh_resolve_output+0x5e2/0xa00 net/core/neighbour.c:1350
neigh_output include/net/neighbour.h:482 [inline]
ip6_finish_output2+0xb4a/0x23a0 net/ipv6/ip6_output.c:120
ip6_finish_output+0x698/0xaf0 net/ipv6/ip6_output.c:154
NF_HOOK_COND include/linux/netfilter.h:277 [inline]
ip6_output+0x1eb/0x840 net/ipv6/ip6_output.c:171
dst_output include/net/dst.h:443 [inline]
NF_HOOK include/linux/netfilter.h:288 [inline]
ndisc_send_skb+0xac4/0x1370 net/ipv6/ndisc.c:491
ndisc_send_ns+0x38a/0x870 net/ipv6/ndisc.c:628
addrconf_dad_work+0x980/0x12b0 net/ipv6/addrconf.c:3997
process_one_work+0xbbf/0x1af0 kernel/workqueue.c:2112
worker_thread+0x223/0x1990 kernel/workqueue.c:2246
kthread+0x33c/0x400 kernel/kthread.c:238
ret_from_fork+0x37/0x50 arch/x86/entry/entry_64.S:530

The buggy address belongs to the object at ffff8801bc753bc0
which belongs to the cache skbuff_head_cache of size 232
The buggy address is located 40 bytes inside of
232-byte region [ffff8801bc753bc0, ffff8801bc753ca8)
The buggy address belongs to the page:
page:ffffea0006f1d4c0 count:1 mapcount:0 mapping:ffff8801bc753080 index:0x0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffff8801bc753080 0000000000000000 000000010000000c
raw: ffffea0006f271e0 ffffea0006f270a0 ffff8801d986ccc0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8801bc753a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801bc753b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc
> ffff8801bc753b80: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
^
ffff8801bc753c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801bc753c80: fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc
==================================================================


---
This bug is generated by a dumb bot. It may contain errors.
See https://goo.gl/tpsmEJ for details.
Direct all questions to syzk...@googlegroups.com.

syzbot will keep track of this bug report.
If you forgot to add the Reported-by tag, once the fix for this bug is
merged
into any tree, please reply to this email with:
#syz fix: exact-commit-title
To mark this as a duplicate of another syzbot report, please reply with:
#syz dup: exact-subject-of-another-report
If it's a one-off invalid bug report, please reply with:
#syz invalid
Note: if the crash happens again, it will cause creation of a new bug
report.
Note: all commands must start from beginning of the line in the email body.
config.txt
raw.log.txt

syzbot

unread,
Mar 14, 2018, 7:30:03 PM3/14/18
to da...@davemloft.net, j...@mojatatu.com, ji...@resnulli.us, linux-...@vger.kernel.org, net...@vger.kernel.org, syzkall...@googlegroups.com, xiyou.w...@gmail.com
syzbot has found reproducer for the following crash on net-next commit
a870a02cc963de35452bbed932560ed69725c4f2 (Tue Mar 13 20:58:39 2018 +0000)
pktgen: use dynamic allocation for debug print buffer

So far this crash happened 7 times on mmots, net-next.
C reproducer is attached.
syzkaller reproducer is attached.
Raw console output is attached.
compiler: gcc (GCC) 7.1.1 20170620
.config is attached.

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+ed43b6...@syzkaller.appspotmail.com
It will help syzbot understand when the bug is fixed.

==================================================================
BUG: KASAN: use-after-free in qdisc_pkt_len include/net/sch_generic.h:610
[inline]
BUG: KASAN: use-after-free in qdisc_qstats_cpu_backlog_inc
include/net/sch_generic.h:712 [inline]
BUG: KASAN: use-after-free in pfifo_fast_enqueue+0x4bc/0x5e0
net/sched/sch_generic.c:639
Read of size 4 at addr ffff8801cede37e8 by task syzkaller717588/5543

CPU: 1 PID: 5543 Comm: syzkaller717588 Not tainted 4.16.0-rc4+ #265
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x194/0x24d lib/dump_stack.c:53
print_address_description+0x73/0x250 mm/kasan/report.c:256
kasan_report_error mm/kasan/report.c:354 [inline]
kasan_report+0x23c/0x360 mm/kasan/report.c:412
__asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:432
qdisc_pkt_len include/net/sch_generic.h:610 [inline]
qdisc_qstats_cpu_backlog_inc include/net/sch_generic.h:712 [inline]
pfifo_fast_enqueue+0x4bc/0x5e0 net/sched/sch_generic.c:639
__dev_xmit_skb net/core/dev.c:3216 [inline]
__dev_queue_xmit+0xd50/0x2f30 net/core/dev.c:3517
dev_queue_xmit+0x17/0x20 net/core/dev.c:3582
neigh_hh_output include/net/neighbour.h:472 [inline]
neigh_output include/net/neighbour.h:480 [inline]
ip6_finish_output2+0x1472/0x23d0 net/ipv6/ip6_output.c:120
ip6_finish_output+0x69b/0xaf0 net/ipv6/ip6_output.c:154
NF_HOOK_COND include/linux/netfilter.h:277 [inline]
ip6_output+0x1eb/0x840 net/ipv6/ip6_output.c:171
dst_output include/net/dst.h:444 [inline]
ip6_local_out+0x95/0x160 net/ipv6/output_core.c:176
ip6_send_skb+0xa1/0x330 net/ipv6/ip6_output.c:1677
ip6_push_pending_frames+0xb3/0xe0 net/ipv6/ip6_output.c:1697
rawv6_push_pending_frames net/ipv6/raw.c:616 [inline]
rawv6_sendmsg+0x2f96/0x40c0 net/ipv6/raw.c:935
inet_sendmsg+0x11f/0x5e0 net/ipv4/af_inet.c:763
sock_sendmsg_nosec net/socket.c:629 [inline]
sock_sendmsg+0xca/0x110 net/socket.c:639
___sys_sendmsg+0x320/0x8b0 net/socket.c:2047
__sys_sendmmsg+0x1ee/0x620 net/socket.c:2137
SYSC_sendmmsg net/socket.c:2168 [inline]
SyS_sendmmsg+0x35/0x60 net/socket.c:2163
do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x447739
RSP: 002b:00007fb444290d58 EFLAGS: 00000297 ORIG_RAX: 0000000000000133
RAX: ffffffffffffffda RBX: 00000000006f0084 RCX: 0000000000447739
RDX: 0000000000000249 RSI: 0000000020001300 RDI: 0000000000000353
RBP: 0000000000000000 R08: 0000000020000000 R09: 0000000020000000
R10: 0000000000000000 R11: 0000000000000297 R12: 00000000006f0080
R13: 00000000007ffd8f R14: 00007fb4442919c0 R15: 000000000000000a

Allocated by task 5543:
save_stack+0x43/0xd0 mm/kasan/kasan.c:447
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:552
kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:489
kmem_cache_alloc_node+0x144/0x760 mm/slab.c:3631
__alloc_skb+0xf1/0x780 net/core/skbuff.c:193
alloc_skb include/linux/skbuff.h:986 [inline]
sock_wmalloc+0x140/0x1d0 net/core/sock.c:1942
__ip6_append_data.isra.43+0x26b9/0x3390 net/ipv6/ip6_output.c:1416
ip6_append_data+0x189/0x290 net/ipv6/ip6_output.c:1571
rawv6_sendmsg+0x1e09/0x40c0 net/ipv6/raw.c:928
inet_sendmsg+0x11f/0x5e0 net/ipv4/af_inet.c:763
sock_sendmsg_nosec net/socket.c:629 [inline]
sock_sendmsg+0xca/0x110 net/socket.c:639
___sys_sendmsg+0x320/0x8b0 net/socket.c:2047
__sys_sendmmsg+0x1ee/0x620 net/socket.c:2137
SYSC_sendmmsg net/socket.c:2168 [inline]
SyS_sendmmsg+0x35/0x60 net/socket.c:2163
do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 5531:
save_stack+0x43/0xd0 mm/kasan/kasan.c:447
set_track mm/kasan/kasan.c:459 [inline]
__kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:520
kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:527
__cache_free mm/slab.c:3485 [inline]
kmem_cache_free+0x83/0x2a0 mm/slab.c:3743
kfree_skbmem+0x1a1/0x1d0 net/core/skbuff.c:582
__kfree_skb net/core/skbuff.c:642 [inline]
kfree_skb+0x165/0x4c0 net/core/skbuff.c:659
ip_tunnel_xmit+0x710/0x3550 net/ipv4/ip_tunnel.c:778
__gre_xmit+0x546/0x8b0 net/ipv4/ip_gre.c:449
erspan_xmit+0x779/0x22a0 net/ipv4/ip_gre.c:731
__netdev_start_xmit include/linux/netdevice.h:4078 [inline]
netdev_start_xmit include/linux/netdevice.h:4087 [inline]
xmit_one net/core/dev.c:3026 [inline]
dev_hard_start_xmit+0x24e/0xac0 net/core/dev.c:3042
sch_direct_xmit+0x40d/0x1140 net/sched/sch_generic.c:327
qdisc_restart net/sched/sch_generic.c:393 [inline]
__qdisc_run+0x57d/0x19c0 net/sched/sch_generic.c:401
__dev_xmit_skb net/core/dev.c:3217 [inline]
__dev_queue_xmit+0xd5e/0x2f30 net/core/dev.c:3517
dev_queue_xmit+0x17/0x20 net/core/dev.c:3582
neigh_hh_output include/net/neighbour.h:472 [inline]
neigh_output include/net/neighbour.h:480 [inline]
ip6_finish_output2+0x1472/0x23d0 net/ipv6/ip6_output.c:120
ip6_finish_output+0x69b/0xaf0 net/ipv6/ip6_output.c:154
NF_HOOK_COND include/linux/netfilter.h:277 [inline]
ip6_output+0x1eb/0x840 net/ipv6/ip6_output.c:171
dst_output include/net/dst.h:444 [inline]
ip6_local_out+0x95/0x160 net/ipv6/output_core.c:176
ip6_send_skb+0xa1/0x330 net/ipv6/ip6_output.c:1677
ip6_push_pending_frames+0xb3/0xe0 net/ipv6/ip6_output.c:1697
rawv6_push_pending_frames net/ipv6/raw.c:616 [inline]
rawv6_sendmsg+0x2f96/0x40c0 net/ipv6/raw.c:935
inet_sendmsg+0x11f/0x5e0 net/ipv4/af_inet.c:763
sock_sendmsg_nosec net/socket.c:629 [inline]
sock_sendmsg+0xca/0x110 net/socket.c:639
___sys_sendmsg+0x320/0x8b0 net/socket.c:2047
__sys_sendmmsg+0x1ee/0x620 net/socket.c:2137
SYSC_sendmmsg net/socket.c:2168 [inline]
SyS_sendmmsg+0x35/0x60 net/socket.c:2163
do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
entry_SYSCALL_64_after_hwframe+0x42/0xb7

The buggy address belongs to the object at ffff8801cede37c0
which belongs to the cache skbuff_head_cache of size 232
The buggy address is located 40 bytes inside of
232-byte region [ffff8801cede37c0, ffff8801cede38a8)
The buggy address belongs to the page:
page:ffffea00073b78c0 count:1 mapcount:0 mapping:ffff8801cede3040 index:0x0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffff8801cede3040 0000000000000000 000000010000000c
raw: ffffea00074946a0 ffffea00074c6d60 ffff8801d940fcc0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8801cede3680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801cede3700: fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc
> ffff8801cede3780: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
^
ffff8801cede3800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801cede3880: fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc
==================================================================

raw.log.txt
repro.syz.txt
repro.c.txt
config.txt

Eric Dumazet

unread,
Mar 14, 2018, 8:16:13 PM3/14/18
to syzbot, da...@davemloft.net, j...@mojatatu.com, ji...@resnulli.us, linux-...@vger.kernel.org, net...@vger.kernel.org, syzkall...@googlegroups.com, xiyou.w...@gmail.com
typical use after free...

diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 190570f21b208d5a17943360a3a6f85e1c2a2187..663e016491773f40f81d9bbfeab3dd68e1c2fc5c 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -628,6 +628,7 @@ static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc *qdisc,
int band = prio2band[skb->priority & TC_PRIO_MAX];
struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
struct skb_array *q = band2list(priv, band);
+ unsigned int pkt_len = qdisc_pkt_len(skb);
int err;

err = skb_array_produce(q, skb);
@@ -636,7 +637,7 @@ static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc *qdisc,
return qdisc_drop_cpu(skb, qdisc, to_free);

qdisc_qstats_cpu_qlen_inc(qdisc);
- qdisc_qstats_cpu_backlog_inc(qdisc, skb);
+ this_cpu_add(qdisc->cpu_qstats->backlog, pkt_len);
return NET_XMIT_SUCCESS;
}

Eric Dumazet

unread,
Mar 14, 2018, 8:47:13 PM3/14/18
to syzbot, da...@davemloft.net, j...@mojatatu.com, ji...@resnulli.us, linux-...@vger.kernel.org, net...@vger.kernel.org, syzkall...@googlegroups.com, xiyou.w...@gmail.com


On 03/14/2018 05:16 PM, Eric Dumazet wrote:

>
> typical use after free...
>
> diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
> index 190570f21b208d5a17943360a3a6f85e1c2a2187..663e016491773f40f81d9bbfeab3dd68e1c2fc5c 100644
> --- a/net/sched/sch_generic.c
> +++ b/net/sched/sch_generic.c
> @@ -628,6 +628,7 @@ static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc *qdisc,
> int band = prio2band[skb->priority & TC_PRIO_MAX];
> struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
> struct skb_array *q = band2list(priv, band);
> + unsigned int pkt_len = qdisc_pkt_len(skb);
> int err;
>
> err = skb_array_produce(q, skb);
> @@ -636,7 +637,7 @@ static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc *qdisc,
> return qdisc_drop_cpu(skb, qdisc, to_free);
>
> qdisc_qstats_cpu_qlen_inc(qdisc);
> - qdisc_qstats_cpu_backlog_inc(qdisc, skb);
> + this_cpu_add(qdisc->cpu_qstats->backlog, pkt_len);
> return NET_XMIT_SUCCESS;
> }
>
There is also a similar issue right after qdisc_enqueue_skb_bad_txq() call.

We should move the following code in qdisc_enqueue_skb_bad_txq() to benefit from the locking

if (qdisc_is_percpu_stats(q)) {
qdisc_qstats_cpu_backlog_inc(q, nskb);
qdisc_qstats_cpu_qlen_inc(q);
} else {
qdisc_qstats_backlog_inc(q, nskb);
q->q.qlen++;
}


I will post a patch with the two fixes.
Reply all
Reply to author
Forward
0 new messages