From: Guenter Roeck <linux@roeck-us.net>
To: Nhat Tran <nhat.tranminhk2@gmail.com>
Cc: Wim Van Sebroeck <wim@linux-watchdog.org>,
Lars Poeschel <poeschel@lemonage.de>,
linux-watchdog@vger.kernel.org, linux-omap@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2] watchdog: core: Don't report time left for a stopped watchdog
Date: Sat, 21 Nov 2026 07:26:12 -0800 [thread overview]
Message-ID: <08729e0f-874f-41cb-b6ee-bff6207c1cb4@roeck-us.net> (raw)
In-Reply-To: <20261121052950.287506-1-nhat.tranminhk2@gmail.com>
On Sat, Nov 21, 2026 at 12:29:50PM +0700, Nhat Tran wrote:
> watchdog_get_timeleft() calls the driver's ->get_timeleft() regardless
> of whether the watchdog is running. It is reachable through the sysfs
> timeleft attribute, which is world readable with CONFIG_WATCHDOG_SYSFS=y,
> and through WDIOC_GETTIMELEFT, also after the watchdog was stopped with
> WDIOS_DISABLECARD while the device is still open.
>
> Drivers may not be able to access the hardware while the watchdog is
> stopped. omap_wdt only holds a runtime PM reference while the watchdog
> is running, so on a BeagleBone Black (AM335x) reading the counter of a
> stopped watchdog triggers an external abort. Any unprivileged user can
> hit it through sysfs:
>
> $ cat /sys/class/watchdog/watchdog0/timeleft
> Unhandled fault: external abort on non-linefetch (0x1028) at 0xf9e35028
> Internal error: : 1028 [#1] SMP ARM
> PC is at omap_wdt_get_timeleft+0x4/0x14
> LR is at watchdog_get_timeleft+0x24/0x130
> Call trace:
> omap_wdt_get_timeleft from watchdog_get_timeleft+0x24/0x130
> watchdog_get_timeleft from timeleft_show+0x3c/0x80
> timeleft_show from dev_attr_show+0x18/0x4c
> dev_attr_show from sysfs_kf_seq_show+0xa0/0x138
> ...
>
> and the same happens with WDIOS_DISABLECARD followed by
> WDIOC_GETTIMELEFT on the open device, once the module has idled:
>
> Call trace:
> omap_wdt_get_timeleft from watchdog_get_timeleft+0x24/0x130
> watchdog_get_timeleft from watchdog_ioctl+0x494/0x668
> watchdog_ioctl from sys_ioctl+0x128/0xbcc
> sys_ioctl from ret_fast_syscall+0x0/0x54
>
> If the ioctl comes before the module has idled, the read succeeds but
> reports 59 seconds left for a watchdog that is stopped.
>
> A stopped watchdog will not reboot the system, so report 0 time left
> when neither WDOG_ACTIVE nor WDOG_HW_RUNNING is set, without calling
> into the driver. This matches the software fallback for drivers without
> ->get_timeleft(), which already decays to 0 once the watchdog is no
> longer pinged.
>
> Tested on a BeagleBone Black: with the watchdog stopped, both the sysfs
> attribute and WDIOC_GETTIMELEFT after WDIOS_DISABLECARD return 0; with
> the watchdog started through /dev/watchdog0, timeleft counts down as
> before (59, then 56 three seconds later).
>
> Fixes: 452fafed839e ("watchdog: omap_wdt: implement get_timeleft")
> Cc: stable@vger.kernel.org
> Suggested-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Nhat Tran <nhat.tranminhk2@gmail.com>
Applied, and thanks for testing with WDIOS_DISABLECARD/WDIOC_GETTIMELEFT.
Thanks,
Guenter
prev parent reply other threads:[~2026-11-21 15:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 5:29 Nhat Tran
2026-11-21 15:26 ` Guenter Roeck [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=08729e0f-874f-41cb-b6ee-bff6207c1cb4@roeck-us.net \
--to=linux@roeck-us.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=nhat.tranminhk2@gmail.com \
--cc=poeschel@lemonage.de \
--cc=stable@vger.kernel.org \
--cc=wim@linux-watchdog.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®