Krzysztof Sobota
3fcd24040f
watchdog: initialize device before misc_register
[ Upstream commit cb36e29bb0e4b0c33c3d5866a0a4aebace4c99b7 ]
When watchdog device is being registered, it calls misc_register that
makes watchdog available for systemd to open. This is a data race
scenario, because when device is open it may still have device struct
not initialized - this in turn causes a crash. This patch moves
device initialization before misc_register call and it solves the
problem printed below.
------------[ cut here ]------------
WARNING: CPU: 3 PID: 1 at lib/kobject.c:612 kobject_get+0x50/0x54
kobject: '(null)' ((ptrval)): is not initialized, yet kobject_get() is being called.
Modules linked in: k2_reset_status(O) davinci_wdt(+) sfn_platform_hwbcn(O) fsmddg_sfn(O) clk_misc_mmap(O) clk_sw_bcn(O) fsp_reset(O) cma_mod(O) slave_sup_notif(O) fpga_master(O) latency(O+) evnotify(O) enable_arm_pmu(O) xge(O) rio_mport_cdev br_netfilter bridge stp llc nvrd_checksum(O) ipv6
CPU: 3 PID: 1 Comm: systemd Tainted: G O 4.19.113-g2579778-fsm4_k2 #1
Hardware name: Keystone
[<c02126c4>] (unwind_backtrace) from [<c020da94>] (show_stack+0x18/0x1c)
[<c020da94>] (show_stack) from [<c07f87d8>] (dump_stack+0xb4/0xe8)
[<c07f87d8>] (dump_stack) from [<c0221f70>] (__warn+0xfc/0x114)
[<c0221f70>] (__warn) from [<c0221fd8>] (warn_slowpath_fmt+0x50/0x74)
[<c0221fd8>] (warn_slowpath_fmt) from [<c07fd394>] (kobject_get+0x50/0x54)
[<c07fd394>] (kobject_get) from [<c0602ce8>] (get_device+0x1c/0x24)
[<c0602ce8>] (get_device) from [<c06961e0>] (watchdog_open+0x90/0xf0)
[<c06961e0>] (watchdog_open) from [<c06001dc>] (misc_open+0x130/0x17c)
[<c06001dc>] (misc_open) from [<c0388228>] (chrdev_open+0xec/0x1a8)
[<c0388228>] (chrdev_open) from [<c037fa98>] (do_dentry_open+0x204/0x3cc)
[<c037fa98>] (do_dentry_open) from [<c0391e2c>] (path_openat+0x330/0x1148)
[<c0391e2c>] (path_openat) from [<c0394518>] (do_filp_open+0x78/0xec)
[<c0394518>] (do_filp_open) from [<c0381100>] (do_sys_open+0x130/0x1f4)
[<c0381100>] (do_sys_open) from [<c0201000>] (ret_fast_syscall+0x0/0x28)
Exception stack(0xd2ceffa8 to 0xd2cefff0)
ffa0: b6f69968 00000000 ffffff9c b6ebd210 000a0001 00000000
ffc0: b6f69968 00000000 00000000 00000142 fffffffd ffffffff 00b65530 bed7bb78
ffe0: 00000142 bed7ba70 b6cc2503 b6cc41d6
---[ end trace 7b16eb105513974f ]---
------------[ cut here ]------------
WARNING: CPU: 3 PID: 1 at lib/refcount.c:153 kobject_get+0x24/0x54
refcount_t: increment on 0; use-after-free.
Modules linked in: k2_reset_status(O) davinci_wdt(+) sfn_platform_hwbcn(O) fsmddg_sfn(O) clk_misc_mmap(O) clk_sw_bcn(O) fsp_reset(O) cma_mod(O) slave_sup_notif(O) fpga_master(O) latency(O+) evnotify(O) enable_arm_pmu(O) xge(O) rio_mport_cdev br_netfilter bridge stp llc nvrd_checksum(O) ipv6
CPU: 3 PID: 1 Comm: systemd Tainted: G W O 4.19.113-g2579778-fsm4_k2 #1
Hardware name: Keystone
[<c02126c4>] (unwind_backtrace) from [<c020da94>] (show_stack+0x18/0x1c)
[<c020da94>] (show_stack) from [<c07f87d8>] (dump_stack+0xb4/0xe8)
[<c07f87d8>] (dump_stack) from [<c0221f70>] (__warn+0xfc/0x114)
[<c0221f70>] (__warn) from [<c0221fd8>] (warn_slowpath_fmt+0x50/0x74)
[<c0221fd8>] (warn_slowpath_fmt) from [<c07fd368>] (kobject_get+0x24/0x54)
[<c07fd368>] (kobject_get) from [<c0602ce8>] (get_device+0x1c/0x24)
[<c0602ce8>] (get_device) from [<c06961e0>] (watchdog_open+0x90/0xf0)
[<c06961e0>] (watchdog_open) from [<c06001dc>] (misc_open+0x130/0x17c)
[<c06001dc>] (misc_open) from [<c0388228>] (chrdev_open+0xec/0x1a8)
[<c0388228>] (chrdev_open) from [<c037fa98>] (do_dentry_open+0x204/0x3cc)
[<c037fa98>] (do_dentry_open) from [<c0391e2c>] (path_openat+0x330/0x1148)
[<c0391e2c>] (path_openat) from [<c0394518>] (do_filp_open+0x78/0xec)
[<c0394518>] (do_filp_open) from [<c0381100>] (do_sys_open+0x130/0x1f4)
[<c0381100>] (do_sys_open) from [<c0201000>] (ret_fast_syscall+0x0/0x28)
Exception stack(0xd2ceffa8 to 0xd2cefff0)
ffa0: b6f69968 00000000 ffffff9c b6ebd210 000a0001 00000000
ffc0: b6f69968 00000000 00000000 00000142 fffffffd ffffffff 00b65530 bed7bb78
ffe0: 00000142 bed7ba70 b6cc2503 b6cc41d6
---[ end trace 7b16eb1055139750 ]---
Fixes: 72139dfa2464 ("watchdog: Fix the race between the release of watchdog_core_data and cdev")
Reviewed-by: Guenter Roeck <[email protected]>
Reviewed-by: Alexander Sverdlin <[email protected]>
Signed-off-by: Krzysztof Sobota <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Guenter Roeck <[email protected]>
Signed-off-by: Wim Van Sebroeck <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
|
2020-08-21 13:05:36 +02:00 |
| .. |
|
acquirewdt.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
advantechwdt.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
alim1535_wdt.c
|
|
|
|
alim7101_wdt.c
|
|
|
|
ar7_wdt.c
|
watchdog: Mark expected switch fall-throughs
|
2019-08-12 13:05:37 +02:00 |
|
armada_37xx_wdt.c
|
|
|
|
asm9260_wdt.c
|
|
|
|
aspeed_wdt.c
|
watchdog: aspeed: Fix clock behaviour for ast2600
|
2019-12-13 08:43:30 +01:00 |
|
at91rm9200_wdt.c
|
|
|
|
at91sam9_wdt.c
|
|
|
|
at91sam9_wdt.h
|
|
|
|
ath79_wdt.c
|
watchdog: ath79_wdt: fix a typo in the name of a function
|
2019-07-24 20:21:39 +02:00 |
|
atlas7_wdt.c
|
|
|
|
bcm47xx_wdt.c
|
|
|
|
bcm63xx_wdt.c
|
|
|
|
bcm2835_wdt.c
|
watchdog: bcm2835_wdt: Fix module autoload
|
2019-07-08 16:08:32 +02:00 |
|
bcm7038_wdt.c
|
watchdog: bcm7038_wdt: drop warning after registering device
|
2019-07-08 15:13:02 +02:00 |
|
bcm_kona_wdt.c
|
watchdog: bcm_kona_wdt: no need to check return value of debugfs_create functions
|
2019-07-08 20:35:10 +02:00 |
|
bd70528_wdt.c
|
watchdog: bd70528: Add MODULE_ALIAS to allow module auto loading
|
2019-11-05 16:58:12 +01:00 |
|
booke_wdt.c
|
|
|
|
cadence_wdt.c
|
watchdog: cadence_wdt: drop warning after registering device
|
2019-07-08 15:13:04 +02:00 |
|
coh901327_wdt.c
|
|
|
|
cpu5wdt.c
|
|
|
|
cpwd.c
|
watchdog: cpwd: fix build regression
|
2019-11-05 16:58:11 +01:00 |
|
da9052_wdt.c
|
watchdog: da9052_wdt: drop warning after registering device
|
2019-07-08 15:13:04 +02:00 |
|
da9055_wdt.c
|
|
|
|
da9062_wdt.c
|
watchdog: da9062: No need to ping manually before setting timeout
|
2020-06-24 17:50:32 +02:00 |
|
da9063_wdt.c
|
|
|
|
davinci_wdt.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
diag288_wdt.c
|
watchdog: diag288_wdt: Remove leftover includes from conversion to watchdog API
|
2019-09-17 08:59:01 +02:00 |
|
digicolor_wdt.c
|
watchdog: digicolor_wdt: Remove unused variable in dc_wdt_probe
|
2019-07-15 08:49:11 +02:00 |
|
dw_wdt.c
|
|
|
|
ebc-c384_wdt.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
ep93xx_wdt.c
|
|
|
|
eurotechwdt.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
f71808e_wdt.c
|
watchdog: f71808e_wdt: clear watchdog timeout occurred flag
|
2020-08-21 13:05:28 +02:00 |
|
ftwdt010_wdt.c
|
watchdog: ftwdt010_wdt: drop warning after registering device
|
2019-07-08 15:13:06 +02:00 |
|
gef_wdt.c
|
|
|
|
geodewdt.c
|
|
|
|
gpio_wdt.c
|
watchdog: gpio: add support for nowayout option
|
2019-07-08 19:39:44 +02:00 |
|
hpwdt.c
|
watchdog/hpwdt: Reflect changes
|
2019-07-08 16:10:10 +02:00 |
|
i6300esb.c
|
watchdog: i6300esb: drop warning after registering device
|
2019-07-08 15:13:06 +02:00 |
|
ib700wdt.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
ibmasr.c
|
|
|
|
ie6xx_wdt.c
|
watchdog: ie6xx_wdt: Use spinlock_t instead of struct spinlock
|
2019-07-08 20:46:48 +02:00 |
|
imgpdc_wdt.c
|
|
|
|
imx2_wdt.c
|
watchdog: imx2_wdt: fix min() calculation in imx2_wdt_set_timeout
|
2019-09-17 08:59:02 +02:00 |
|
imx7ulp_wdt.c
|
watchdog: imx7ulp: Fix reboot hang
|
2020-01-04 19:18:13 +01:00 |
|
imx_sc_wdt.c
|
watchdog: imx_sc_wdt: Fix reboot on crash
|
2020-06-17 16:40:27 +02:00 |
|
indydog.c
|
|
|
|
intel-mid_wdt.c
|
watchdog: intel-mid_wdt: drop warning after registering device
|
2019-07-08 15:13:08 +02:00 |
|
intel_scu_watchdog.c
|
|
|
|
intel_scu_watchdog.h
|
|
|
|
iop_wdt.c
|
|
|
|
it87_wdt.c
|
|
|
|
it8712f_wdt.c
|
|
|
|
iTCO_vendor.h
|
watchdog: iTCO_wdt: Export vendorsupport
|
2020-04-08 09:08:46 +02:00 |
|
iTCO_vendor_support.c
|
watchdog: iTCO_wdt: Export vendorsupport
|
2020-04-08 09:08:46 +02:00 |
|
iTCO_wdt.c
|
watchdog: iTCO_wdt: Make ICH_RES_IO_SMI optional
|
2020-04-08 09:08:46 +02:00 |
|
ixp4xx_wdt.c
|
|
|
|
jz4740_wdt.c
|
watchdog: jz4740: Fix unused variable warning in jz4740_wdt_probe
|
2019-08-12 13:05:39 +02:00 |
|
Kconfig
|
watchdog: max77620_wdt: fix potential build errors
|
2020-02-01 09:34:43 +00:00 |
|
kempld_wdt.c
|
|
|
|
lantiq_wdt.c
|
|
|
|
loongson1_wdt.c
|
watchdog: loongson1_wdt: drop warning after registering device
|
2019-07-08 15:13:08 +02:00 |
|
lpc18xx_wdt.c
|
|
|
|
m54xx_wdt.c
|
|
|
|
machzwd.c
|
|
|
|
Makefile
|
watchdog: Add i.MX7ULP watchdog support
|
2019-09-17 08:59:12 +02:00 |
|
max63xx_wdt.c
|
|
|
|
max77620_wdt.c
|
watchdog: max77620_wdt: drop warning after registering device
|
2019-07-08 15:13:09 +02:00 |
|
mei_wdt.c
|
watchdog: mei_wdt: no need to check return value of debugfs_create functions
|
2019-07-08 20:35:10 +02:00 |
|
mena21_wdt.c
|
watchdog: mena21_wdt: drop warning after registering device
|
2019-07-08 15:13:09 +02:00 |
|
menf21bmc_wdt.c
|
watchdog: menf21bmc_wdt: drop warning after registering device
|
2019-07-08 15:13:10 +02:00 |
|
menz69_wdt.c
|
|
|
|
meson_gxbb_wdt.c
|
watchdog: meson: Fix the wrong value of left time
|
2019-11-05 16:58:12 +01:00 |
|
meson_wdt.c
|
|
|
|
mixcomwd.c
|
|
|
|
mlx_wdt.c
|
|
|
|
moxart_wdt.c
|
|
|
|
mpc8xxx_wdt.c
|
watchdog: mpc8xxx_wdt: drop warning after registering device
|
2019-07-08 15:13:10 +02:00 |
|
mt7621_wdt.c
|
|
|
|
mtk_wdt.c
|
|
|
|
mtx-1_wdt.c
|
|
|
|
mv64x60_wdt.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
ni903x_wdt.c
|
watchdog: ni903x_wdt: drop warning after registering device
|
2019-07-08 15:13:10 +02:00 |
|
nic7018_wdt.c
|
watchdog: nic7018_wdt: drop warning after registering device
|
2019-07-08 15:13:11 +02:00 |
|
npcm_wdt.c
|
watchdog: npcm_wdt: drop warning after registering device
|
2019-07-08 15:13:11 +02:00 |
|
nv_tco.c
|
|
|
|
nv_tco.h
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
octeon-wdt-main.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
octeon-wdt-nmi.S
|
|
|
|
of_xilinx_wdt.c
|
watchdog: of_xilinx_wdt: drop warning after registering device
|
2019-07-08 15:13:12 +02:00 |
|
omap_wdt.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
omap_wdt.h
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
orion_wdt.c
|
watchdog: orion: fix platform_get_irq() complaints
|
2020-02-01 09:34:43 +00:00 |
|
pc87413_wdt.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
pcwd.c
|
watchdog: Mark expected switch fall-throughs
|
2019-08-12 13:05:37 +02:00 |
|
pcwd_pci.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
pcwd_usb.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
pic32-dmt.c
|
watchdog: pic32-dmt: drop warning after registering device
|
2019-07-08 15:13:12 +02:00 |
|
pic32-wdt.c
|
watchdog: pic32-wdt: drop warning after registering device
|
2019-07-08 15:13:12 +02:00 |
|
pika_wdt.c
|
|
|
|
pm8916_wdt.c
|
watchdog: pm8916_wdt: fix pretimeout registration flow
|
2019-11-05 16:58:11 +01:00 |
|
pnx833x_wdt.c
|
|
|
|
pnx4008_wdt.c
|
watchdog: pnx4008_wdt: allow compile-testing
|
2019-09-16 22:10:05 +02:00 |
|
pretimeout_noop.c
|
|
|
|
pretimeout_panic.c
|
|
|
|
qcom-wdt.c
|
watchdog: qcom: Use platform_get_irq_optional() for bark irq
|
2020-02-14 16:34:12 -05:00 |
|
rave-sp-wdt.c
|
watchdog: rave-sp-wdt: drop warning after registering device
|
2019-07-08 15:13:14 +02:00 |
|
rc32434_wdt.c
|
|
|
|
rdc321x_wdt.c
|
|
|
|
renesas_wdt.c
|
watchdog: renesas_wdt: Add a few cycles delay
|
2019-07-08 19:39:44 +02:00 |
|
retu_wdt.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
riowd.c
|
watchdog: riowd: Mark expected switch fall-through
|
2019-08-12 13:05:38 +02:00 |
|
rn5t618_wdt.c
|
watchdog: rn5t618_wdt: fix module aliases
|
2020-02-01 09:34:43 +00:00 |
|
rt2880_wdt.c
|
|
|
|
rtd119x_wdt.c
|
|
|
|
rza_wdt.c
|
|
|
|
s3c2410_wdt.c
|
watchdog: s3c2410_wdt: drop warning after registering device
|
2019-07-08 15:13:14 +02:00 |
|
sa1100_wdt.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
sama5d4_wdt.c
|
watchdog: atmel: atmel-sama5d4-wdt: Disable watchdog on system suspend
|
2019-07-08 20:35:12 +02:00 |
|
sb_wdog.c
|
watchdog: Mark expected switch fall-throughs
|
2019-08-12 13:05:37 +02:00 |
|
sbc60xxwdt.c
|
|
|
|
sbc7240_wdt.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
sbc8360.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
sbc_epx_c3.c
|
|
|
|
sbc_fitpc2_wdt.c
|
|
|
|
sbsa_gwdt.c
|
|
|
|
sc520_wdt.c
|
|
|
|
sc1200wdt.c
|
|
|
|
sch311x_wdt.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
scx200_wdt.c
|
watchdog: scx200_wdt: Mark expected switch fall-through
|
2019-08-12 13:05:37 +02:00 |
|
shwdt.c
|
|
|
|
sirfsoc_wdt.c
|
|
|
|
smsc37b787_wdt.c
|
docs: watchdog: convert docs to ReST and rename to *.rst
|
2019-07-08 20:35:09 +02:00 |
|
softdog.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
sp805_wdt.c
|
watchdog: sp805: fix restart handler
|
2020-04-23 10:36:15 +02:00 |
|
sp5100_tco.c
|
watchdog: sp5100_tco: drop warning after registering device
|
2019-07-08 15:13:15 +02:00 |
|
sp5100_tco.h
|
|
|
|
sprd_wdt.c
|
watchdog: sprd: Fix the incorrect pointer getting from driver data
|
2020-01-26 10:01:02 +01:00 |
|
st_lpc_wdt.c
|
watchdog: st_lpc_wdt: drop warning after registering device
|
2019-07-08 15:13:16 +02:00 |
|
stm32_iwdg.c
|
drivers: watchdog: stm32_iwdg: set WDOG_HW_RUNNING at probe
|
2020-02-14 16:34:18 -05:00 |
|
stmp3xxx_rtc_wdt.c
|
watchdog: stmp3xxx_rtc_wdt: drop warning after registering device
|
2019-07-08 15:13:17 +02:00 |
|
stpmic1_wdt.c
|
|
|
|
sun4v_wdt.c
|
|
|
|
sunxi_wdt.c
|
|
|
|
tangox_wdt.c
|
|
|
|
tegra_wdt.c
|
watchdog: tegra_wdt: drop warning after registering device
|
2019-07-08 15:13:17 +02:00 |
|
tqmx86_wdt.c
|
|
|
|
ts72xx_wdt.c
|
|
|
|
ts4800_wdt.c
|
watchdog: ts4800_wdt: drop warning after registering device
|
2019-07-08 15:13:17 +02:00 |
|
twl4030_wdt.c
|
|
|
|
txx9wdt.c
|
|
|
|
uniphier_wdt.c
|
|
|
|
ux500_wdt.c
|
|
|
|
via_wdt.c
|
|
|
|
w83627hf_wdt.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
w83877f_wdt.c
|
|
|
|
w83977f_wdt.c
|
|
|
|
wafer5823wdt.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
watchdog_core.c
|
watchdog: fix UAF in reboot notifier handling in watchdog core code
|
2020-02-11 04:35:37 -08:00 |
|
watchdog_core.h
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
watchdog_dev.c
|
watchdog: initialize device before misc_register
|
2020-08-21 13:05:36 +02:00 |
|
watchdog_pretimeout.c
|
|
|
|
watchdog_pretimeout.h
|
|
|
|
wd501p.h
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
wdat_wdt.c
|
ACPI: watchdog: Set default timeout in probe
|
2020-03-21 08:11:48 +01:00 |
|
wdrtas.c
|
|
|
|
wdt.c
|
watchdog: Mark expected switch fall-throughs
|
2019-08-12 13:05:37 +02:00 |
|
wdt285.c
|
watchdog: wdt285: Mark expected switch fall-through
|
2019-08-20 19:43:23 -05:00 |
|
wdt977.c
|
watchdog: wdt977: Mark expected switch fall-through
|
2019-08-12 13:05:38 +02:00 |
|
wdt_pci.c
|
watchdog: convert remaining drivers to use SPDX license identifier
|
2019-07-08 20:35:11 +02:00 |
|
wm831x_wdt.c
|
watchdog: wm831x_wdt: drop warning after registering device
|
2019-07-08 15:13:18 +02:00 |
|
wm8350_wdt.c
|
|
|
|
xen_wdt.c
|
watchdog: xen_wdt: drop warning after registering device
|
2019-07-08 15:13:18 +02:00 |
|
ziirave_wdt.c
|
watchdog: ziirave_wdt: Update checked I2C functionality mask
|
2019-09-17 08:59:09 +02:00 |
|
zx2967_wdt.c
|
|
|