lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 12 May 2021 11:34:37 +0000
From:   Robin Gong <yibin.gong@....com>
To:     Guenter Roeck <linux@...ck-us.net>,
        "wim@...ux-watchdog.org" <wim@...ux-watchdog.org>,
        "shawnguo@...nel.org" <shawnguo@...nel.org>,
        "s.hauer@...gutronix.de" <s.hauer@...gutronix.de>,
        "festevam@...il.com" <festevam@...il.com>
CC:     dl-linux-imx <linux-imx@....com>,
        "kernel@...gutronix.de" <kernel@...gutronix.de>,
        "linux-watchdog@...r.kernel.org" <linux-watchdog@...r.kernel.org>,
        "linux-arm-kernel@...ts.infradead.org" 
        <linux-arm-kernel@...ts.infradead.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v1] watchdog: imx2_wdt: clear WDOG_HW_RUNNING before
 suspend

On 2021/05/11 11:59 Guenter Roeck <groeck7@...il.com> wrote: 
> On 5/11/21 4:20 AM, Robin Gong wrote:
> > Since watchdog_ping_work is not freezable so that it maybe scheduled
> > before imx2_wdt_resume where watchdog clock enabled, hence, kernel
> > will hang in imx2_wdt_ping without clock, and then watchdog reset
> > happen. Prevent the above case by clearing WDOG_HW_RUNNING before
> > suspend, and restore it with ping in imx2_wdt_resume.
> >
> > Signed-off-by: Robin Gong <yibin.gong@....com>
> > ---
> >   drivers/watchdog/imx2_wdt.c | 8 ++++++++
> >   1 file changed, 8 insertions(+)
> >
> > diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
> > index b84f80f..d3751e9 100644
> > --- a/drivers/watchdog/imx2_wdt.c
> > +++ b/drivers/watchdog/imx2_wdt.c
> > @@ -357,6 +357,13 @@ static int __maybe_unused
> imx2_wdt_suspend(struct device *dev)
> >   		 */
> >   		__imx2_wdt_set_timeout(wdog, IMX2_WDT_MAX_TIME);
> >   		imx2_wdt_ping(wdog);
> > +
> > +		/*
> > +		 * clear WDOG_HW_RUNNING to prevent watchdog_ping_work
> running
> > +		 * before imx2_wdt_resume where clock enabled, otherwise kernel
> > +		 * will hang and watchdog reset happen then.
> > +		 */
> > +		clear_bit(WDOG_HW_RUNNING, &wdog->status);
> >   	}
> >
> >   	clk_disable_unprepare(wdev->clk);
> > @@ -386,6 +393,7 @@ static int __maybe_unused imx2_wdt_resume(struct
> device *dev)
> >   	if (imx2_wdt_is_running(wdev)) {
> >   		imx2_wdt_set_timeout(wdog, wdog->timeout);
> >   		imx2_wdt_ping(wdog);
> > +		set_bit(WDOG_HW_RUNNING, &wdog->status);
> >   	}
> >
> >   	return 0;
> >
> I really don't like this; it depends on assumptions how the watchdog core
> works, and it misuses WDOG_HW_RUNNING to indicate that the clock is
> stopped (or that the driver is in suspend mode).
> 
> If ping doesn't work with the clock stopped, I think it would be much better to
> have a flag indicating that the clock is stopped, and have the ping function do
> nothing if it is called with stopped clock (ie if suspended).
> 
Understood, but I think that corner case should be a common potential issue
in all watchdog drivers which disable clock in suspend with WDOG_HW_RUNNING.
So common way looks better than many different specific flags in such different
watchdog driver with the similar intention?

BTW, for i.mx2_wdt which watchdog can't be stop unless kernel enter into suspend,
that seems like watchdog stop after suspend and clear WDOG_HW_RUNNING makes
sense? 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ