From: Guenter Roeck <linux@roeck-us.net>
To: Tzung-Bi Shih <tzungbi@kernel.org>
Cc: Wim Van Sebroeck <wim@linux-watchdog.org>,
linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] watchdog: pretimeout: Fix UAF in watchdog_unregister_governor()
Date: Wed, 8 Jul 2026 07:06:39 -0700 [thread overview]
Message-ID: <736d014a-5ac8-4ebb-b621-b6ed92693c1a@roeck-us.net> (raw)
In-Reply-To: <20260707101803.3598173-1-tzungbi@kernel.org>
On Tue, Jul 07, 2026 at 10:18:03AM +0000, Tzung-Bi Shih wrote:
> When a watchdog governor is unregistered, it updates existing watchdog
> devices that were using this governor by falling back to `default_gov`.
>
> If the governor being unregistered is currently set as `default_gov`,
> the `default_gov` is never cleared. This leads to 2 use-after-free
> issues:
> 1. New watchdog devices registered after this point will inherit the
> dangling `default_gov`.
> 2. Existing watchdog devices using the unregistered governor will have
> their `wdd->gov` reassigned to the dangling `default_gov`.
>
> Fix the UAF by clearing `default_gov` if it matches the governor being
> unregistered.
>
> Fixes: da0d12ff2b82 ("watchdog: pretimeout: add panic pretimeout governor")
> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Applied.
Thanks,
Guenter
> ---
> drivers/watchdog/watchdog_pretimeout.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/watchdog/watchdog_pretimeout.c b/drivers/watchdog/watchdog_pretimeout.c
> index 19eb2ed2c7cb..02e09b9e396d 100644
> --- a/drivers/watchdog/watchdog_pretimeout.c
> +++ b/drivers/watchdog/watchdog_pretimeout.c
> @@ -167,6 +167,8 @@ void watchdog_unregister_governor(struct watchdog_governor *gov)
> }
>
> spin_lock_irq(&pretimeout_lock);
> + if (default_gov == gov)
> + default_gov = NULL;
> list_for_each_entry(p, &pretimeout_list, entry)
> if (p->wdd->gov == gov)
> p->wdd->gov = default_gov;
prev parent reply other threads:[~2026-07-08 14:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 10:18 Tzung-Bi Shih
2026-07-08 14:06 ` 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=736d014a-5ac8-4ebb-b621-b6ed92693c1a@roeck-us.net \
--to=linux@roeck-us.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=tzungbi@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®