Bug 15366 - sysfs oops when reading current_clocksource if GENERIC_TIME=n
sysfs oops when reading current_clocksource if GENERIC_TIME=n
Status: CLOSED CODE_FIX
Product: Timers
Classification: Unclassified
Component: Other
All Linux
: P1 normal
Assigned To: john stultz
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-02-21 20:19 UTC by Aaro Koskinen
Modified: 2010-04-05 22:07 UTC (History)
2 users (show)

See Also:
Kernel Version: 2.6.32.8
Tree: Mainline
Regression: No


Attachments
[PATCH] Make sure curr_clocksource gets initialized (507 bytes, patch)
2010-02-22 01:50 UTC, john stultz
Details | Diff
Second attempt at getting curr_clocksource initialized (441 bytes, patch)
2010-02-22 20:35 UTC, john stultz
Details | Diff

Description Aaro Koskinen 2010-02-21 20:19:19 UTC
curr_clocksource is uninitialized if GENERIC_TIME=n

# cat /sys/devices/system/clocksource/clocksource0/current_clocksource
[  187.940000] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[  187.960000] pgd = df160000
[  187.960000] [00000000] *pgd=bf11a031, *pte=00000000, *ppte=00000000
[  187.970000] Internal error: Oops: 17 [#1] PREEMPT
[  187.970000] last sysfs file: /sys/devices/system/clocksource/clocksource0/current_clocksource
[  187.970000] Modules linked in:
[  187.970000] CPU: 0    Not tainted  (2.6.32.8-iop32x #13)
[  187.970000] PC is at sysfs_show_current_clocksources+0x2c/0x58
[  187.970000] LR is at sysfs_show_current_clocksources+0x18/0x58
[  187.970000] pc : [<c006b530>]    lr : [<c006b51c>]    psr: 60000013
[  187.970000] sp : df0b9f10  ip : 00000000  fp : beff0cb0
[  187.970000] r10: c043e3cc  r9 : df0eabd8  r8 : df0b9f80
[  187.970000] r7 : 00000fff  r6 : df8be960  r5 : c042e0f8  r4 : df10b000
[  187.970000] r3 : c0472980  r2 : c03b02d8  r1 : 00001000  r0 : df10b000
[  187.970000] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
[  187.970000] Control: 0000397f  Table: bf160000  DAC: 00000015
[  187.970000] Process cat (pid: 514, stack limit = 0xdf0b8270)
[  187.970000] Stack: (0xdf0b9f10 to 0xdf0ba000)
[  187.970000] 9f00:                                     df0eabd8 c042e154 df0eabc0 c01e6f90
[  187.970000] 9f20: c042e154 c0115da8 00100077 df0c87e8 00000021 00001000 00000000 df10fb80
[  187.970000] 9f40: beff0cb0 df0b9f80 00001000 00001000 df0b8000 00000000 00000001 c00c6fc0
[  187.970000] 9f60: c00c45cc c003eff0 00000000 00000000 df10fb80 00001000 beff0cb0 c00c7144
[  187.970000] 9f80: 00000000 00000000 beff1f5f 00000000 00001000 beff0cb0 001da4e0 00000003
[  187.970000] 9fa0: c002a128 c0029f60 00001000 beff0cb0 00000003 beff0cb0 00001000 001d9b30
[  187.970000] 9fc0: 00001000 beff0cb0 001da4e0 00000003 00000001 beff0cb0 00000000 00000001
[  187.970000] 9fe0: 00000003 beff0c90 0000c034 00008d6c 60000010 00000003 ffffffff ffffffff
[  187.970000] [<c006b530>] (sysfs_show_current_clocksources+0x2c/0x58) from [<c01e6f90>] (sysdev_show+0x20/0x28)
[  187.970000] [<c01e6f90>] (sysdev_show+0x20/0x28) from [<c0115da8>] (sysfs_read_file+0x9c/0x130)
[  187.970000] [<c0115da8>] (sysfs_read_file+0x9c/0x130) from [<c00c6fc0>] (vfs_read+0xb0/0x164)
[  187.970000] [<c00c6fc0>] (vfs_read+0xb0/0x164) from [<c00c7144>] (sys_read+0x40/0x70)
[  187.970000] [<c00c7144>] (sys_read+0x40/0x70) from [<c0029f60>] (ret_fast_syscall+0x0/0x38)
[  187.970000] Code: e3a01a01 e59f202c e593c000 e1a00004 (e59c3000)
[  188.170000] ---[ end trace 206df0d3d88ba60c ]---
Comment 1 john stultz 2010-02-22 01:50:14 UTC
Created attachment 25149 [details]
[PATCH] Make sure curr_clocksource gets initialized 

Ugh. Yea, looks like the clocksource rework missed this. 

Here's a test patch that tries to avoid the value being uninitialized. I've not tested it, but let me know if it doesn't resolve the issue.

thanks
-john
Comment 2 Aaro Koskinen 2010-02-22 16:41:08 UTC
(In reply to comment #1)
> Created an attachment (id=25149) [details]
> [PATCH] Make sure curr_clocksource gets initialized 
> 
> Ugh. Yea, looks like the clocksource rework missed this. 
> 
> Here's a test patch that tries to avoid the value being uninitialized. I've not
> tested it, but let me know if it doesn't resolve the issue.

In practice that patch would work, but it will introduce section mismatch warnings:

  CC      kernel/time/clocksource.o
  LD      kernel/time/built-in.o
WARNING: kernel/time/built-in.o(.text+0x1c04): Section mismatch in reference from the function clocksource_unregister() to the function .init.text:clocksource_default_clock()
The function clocksource_unregister() references
the function __init clocksource_default_clock().
This is often because clocksource_unregister lacks a __init
annotation or the annotation of clocksource_default_clock is wrong.

WARNING: kernel/time/built-in.o(.text+0x1c68): Section mismatch in reference from the function __clocksource_change_rating() to the function .init.text:clocksource_default_clock()
The function __clocksource_change_rating() references
the function __init clocksource_default_clock().
This is often because __clocksource_change_rating lacks a __init
annotation or the annotation of clocksource_default_clock is wrong.

WARNING: kernel/time/built-in.o(.text+0x1e1c): Section mismatch in reference from the function sysfs_override_clocksource() to the function .init.text:clocksource_default_clock()
The function sysfs_override_clocksource() references
the function __init clocksource_default_clock().
This is often because sysfs_override_clocksource lacks a __init
annotation or the annotation of clocksource_default_clock is wrong.

WARNING: kernel/time/built-in.o(.text+0x1f10): Section mismatch in reference from the function clocksource_register() to the function .init.text:clocksource_default_clock()
The function clocksource_register() references
the function __init clocksource_default_clock().
This is often because clocksource_register lacks a __init
annotation or the annotation of clocksource_default_clock is wrong.
Comment 3 john stultz 2010-02-22 20:35:37 UTC
Created attachment 25166 [details]
Second attempt at getting curr_clocksource initialized

Thanks for the testing and sorry it wasn't right. Here's another attempt to make sure curr_clocksource is set. Build but not boot tested.

thanks
-john
Comment 4 Aaro Koskinen 2010-02-24 20:06:16 UTC
(In reply to comment #3)
> Created an attachment (id=25166) [details]
> Second attempt at getting curr_clocksource initialized
> 
> Thanks for the testing and sorry it wasn't right. Here's another attempt to
> make sure curr_clocksource is set. Build but not boot tested.

This patch does not have build issues, and even better, my computer does not oops anymore:

# cat /sys/devices/system/clocksource/clocksource0/current_clocksource
jiffies

Thanks. I hope the fix will end up in stable tree (2.6.32.x).
Comment 5 john stultz 2010-02-24 20:26:32 UTC
Aaro, thanks for testing! I'll push this to 2.6.33.x and 2.6.32.x today.
Comment 6 john stultz 2010-04-05 22:07:32 UTC
Patch is upstream.

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