Re: next: runtime warning after 'locking/refcounts: Out-of-line everything'

From: Guenter Roeck
Date: Tue Feb 28 2017 - 13:04:08 EST


On 02/27/2017 11:52 PM, Peter Zijlstra wrote:
On Mon, Feb 27, 2017 at 01:47:47PM -0800, Guenter Roeck wrote:
Hi Peter,

I see the following runtime warning when running a 44x/virtex5_defconfig
image in qemu (virtex-ml507).

refcount_t: underflow; use-after-free.
------------[ cut here ]------------
WARNING: CPU: 0 PID: 1 at lib/refcount.c:128 refcount_sub_and_test+0x90/0xd0
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 4.10.0-next-20170227 #1
task: cf81d5a0 task.stack: cf81e000
NIP: c02100e0 LR: c02100e0 CTR: c0279970
REGS: cf81fc90 TRAP: 0700 Not tainted (4.10.0-next-20170227)
MSR: 00029000 <CE,EE,ME>
CR: 24000022 XER: 00000000

GPR00: c02100e0 cf81fd40 cf81d5a0 00000026 00000000 00000000 c027a3d0 00000000
GPR08: c05403bc 00000800 00000000 00000000 24000024 00000000 c0001ad0 00000000
GPR16: 00000000 00000000 00000000 00000000 00000000 00000000 c054b3c0 c0550000
GPR24: 00000000 00000000 cf948010 00000015 00000000 00000000 cf948000 cfb1c0e8
NIP [c02100e0] refcount_sub_and_test+0x90/0xd0
LR [c02100e0] refcount_sub_and_test+0x90/0xd0
Call Trace:
[cf81fd40] [c02100e0] refcount_sub_and_test+0x90/0xd0 (unreliable)
[cf81fd50] [c01f6564] kobject_put+0x34/0x90
[cf81fd60] [c02ac240] ace_probe+0x410/0x450
[cf81fda0] [c0293684] platform_drv_probe+0x44/0xc0
[cf81fdc0] [c0291494] driver_probe_device+0x234/0x340
[cf81fdf0] [c029166c] __driver_attach+0xcc/0xd0
[cf81fe10] [c028eff8] bus_for_each_dev+0x68/0xc0
[cf81fe40] [c0290838] bus_add_driver+0x208/0x280
[cf81fe60] [c0292198] driver_register+0x88/0x140
[cf81fe70] [c050be10] ace_init+0x48/0xa4
[cf81fe90] [c0001350] do_one_initcall+0x40/0x180
[cf81fef0] [c04f2ae0] kernel_init_freeable+0x134/0x1cc
[cf81ff30] [c0001ae4] kernel_init+0x14/0x110
[cf81ff40] [c000c3d0] ret_from_kernel_thread+0x5c/0x64
Instruction dump:
40a2fff0 7f884840 7d094378 419e0044 2f89ffff 7d434850 7f0a4840 419e0018
4099ffd0 3c60c04b 386393f0 4820e99d <0fe00000> 80010014 38600000 38210010
---[ end trace 17bd7014e44a5b26 ]---
xsysace 83600000.sysace: xsysace: error initializing device at 0x83600000
xsysace 83600000.sysace: could not initialize device, err=-12
xsysace: probe of 83600000.sysace failed with error -12
Xilinx SystemACE device driver, major=254

The complete log is available at
http://kerneltests.org/builders/qemu-ppc-next/builds/590/steps/qemubuildcommand/logs/stdio

Bisect points to commit 29dee3c03abc ("locking/refcounts: Out-of-line
everything'); bisect log is attached. Reverting this commit fixes the problem.

Please let me know if there is anything I can do to help tracking down the
problem.

[ Maybe there is a bug in the ace driver's error handler, but why is it only
seen with your patch applied ? ]

Because it unconditionally enables the WARNs, if you revert but enable
CONFIG_DEBUG_REFCOUNT it should show up as well.


Good point. I'll try to find out what is wrong with that driver.

Thanks,
Guenter