Skip to content

repeatable w1_therm module crash #872

Closed
@Otherbright

Description

@Otherbright

This bug is repeatable if you are waiting/reading the device temperature (for example /sys/bus/w1/devices/28-000006157bcd/w1_slave) while the device is deleted from the system.

I think this kernel function is locked (static ssize_t w1_slave_show(struct device *device,
struct device_attribute *attr, char *buf)) while this function (static void w1_therm_remove_slave(struct w1_slave *sl)) make a kfree on sl->family_data. And the locked function accesses to sl->family_data without checking if sl->family_data is to NULL.

Reference to linux-rpi-3.18.y\drivers\w1\slaves\w1_therm.c.

uname -a
Linux raspberrypi 3.18.8+ #765 PREEMPT Thu Mar 5 15:41:59 GMT 2015 armv6l GNU/Linux

Here is the dmesg:

[   66.375337] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[   66.388108] pgd = da088000
[   66.392523] [00000000] *pgd=1a05c831, *pte=00000000, *ppte=00000000
[   66.401559] Internal error: Oops: 17 [#1] PREEMPT ARM
[   66.408247] Modules linked in: w1_therm w1_gpio wire cn uio_pdrv_genirq uio
[   66.417019] CPU: 0 PID: 2153 Comm: temperature Not tainted 3.18.8+ #765
[   66.425250] task: da04c380 ti: da24c000 task.ti: da24c000
[   66.432294] PC is at w1_slave_show+0x1e4/0x398 [w1_therm]
[   66.439337] LR is at 0x0
[   66.443491] pc : [<bf02e278>]    lr : [<00000000>]    psr: 60000013
[   66.443491] sp : da24de08  ip : 00000000  fp : da24de54
[   66.458308] r10: 000000c9  r9 : da24de27  r8 : da24de27
[   66.465187] r7 : db2ff050  r6 : da01d000  r5 : 00000fd9  r4 : 00000000
[   66.473406] r3 : 00000000  r2 : 00000001  r1 : 00000fd9  r0 : 00000027
[   66.481636] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
[   66.490493] Control: 00c5387d  Table: 1a088008  DAC: 00000015
[   66.497964] Process temperature (pid: 2153, stack limit = 0xda24c1b0)
[   66.506165] Stack: (0xda24de08 to 0xda24e000)
[   66.512298] de00:                   bf02e5dc 00000000 00000000 db358094 db3bf0b0 ff3bf0b0
[   66.524049] de20: ffffffff ffffffff 00000001 da13dea0 bf02e704 da1af240 00001000 da01d000
[   66.535850] de40: c059a364 00000001 da24de6c da24de58 c03604cc bf02e0a0 da13dea0 db2ff058
[   66.547801] de60: da24de94 da24de70 c01aa708 c03604ac da13dea0 00000001 da24deb8 00000000
[   66.559825] de80: 00001000 db39daa0 da24dea4 da24de98 c01a9038 c01aa678 da24def4 da24dea8
[   66.571971] dea0: c015c210 c01a9010 da24c008 da13ded0 b6edc000 da24df78 00000000 00000000
[   66.584289] dec0: da24c028 00000000 da10dd80 da1af240 b6edc000 da24c000 da24df78 00001000
[   66.596756] dee0: b6edc000 00001000 da24df3c da24def8 c01a9a20 c015c064 da24df54 c0137d38
[   66.609408] df00: c01379d4 c0137784 00000001 da24df78 7fffffff db39daa0 b6edc000 da24c000
[   66.622180] df20: da24df78 00001000 b6edc000 00000000 da24df74 da24df40 c0137d64 c01a9908
[   66.635046] df40: da24df5c da24df50 c015525c 00000000 00000000 db39daa3 db39daa0 00001000
[   66.647971] df60: b6edc000 00000000 da24dfa4 da24df78 c0138478 c0137cd8 00000000 00000000
[   66.660898] df80: 01bda980 00000063 00000000 00000003 c000ea84 da24c000 00000000 da24dfa8
[   66.673848] dfa0: c000e800 c0138438 01bda980 00000063 00000004 b6edc000 00001000 00000000
[   66.686795] dfc0: 01bda980 00000063 00000000 00000003 b6c88d20 b6c88fb0 0000000a b6c88d20
[   66.699746] dfe0: 00000000 b6c88c08 b6d85ad8 b6d69ed4 80000010 00000004 00000000 00000000
[   66.712717] [<bf02e278>] (w1_slave_show [w1_therm]) from [<c03604cc>] (dev_attr_show+0x2c/0x58)
[   66.726222] [<c03604cc>] (dev_attr_show) from [<c01aa708>] (sysfs_kf_seq_show+0x9c/0x104)
[   66.739188] [<c01aa708>] (sysfs_kf_seq_show) from [<c01a9038>] (kernfs_seq_show+0x34/0x38)
[   66.752219] [<c01a9038>] (kernfs_seq_show) from [<c015c210>] (seq_read+0x1b8/0x488)
[   66.764619] [<c015c210>] (seq_read) from [<c01a9a20>] (kernfs_fop_read+0x124/0x16c)
[   66.776998] [<c01a9a20>] (kernfs_fop_read) from [<c0137d64>] (vfs_read+0x98/0x188)
[   66.789303] [<c0137d64>] (vfs_read) from [<c0138478>] (SyS_read+0x4c/0xa0)
[   66.798617] [<c0138478>] (SyS_read) from [<c000e800>] (ret_fast_syscall+0x0/0x48)
[   66.810686] Code: eb4ccaa4 e5173004 e2650a01 e1a01005 (e7d33004)
[   66.826414] ---[ end trace f2758d534129f3a2 ]---

Cheers,

Jonathan ALIBERT

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions