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-next>] [day] [month] [year] [list]
Message-ID: <4d82b8ce-bc34-e4b2-c5fe-9e883b0db59d@siemens.com>
Date:   Mon, 13 Sep 2021 13:41:43 +0200
From:   Jan Kiszka <jan.kiszka@...mens.com>
To:     Wim Van Sebroeck <wim@...ux-watchdog.org>,
        Guenter Roeck <linux@...ck-us.net>
Cc:     linux-watchdog@...r.kernel.org,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Tero Kristo <t-kristo@...com>,
        "Su, Bao Cheng (RC-CN DF FA R&D)" <baocheng.su@...mens.com>
Subject: [RFC][PATCH] watchdog: rti-wdt: Provide set_timeout handler to make
 existing userspace happy

From: Jan Kiszka <jan.kiszka@...mens.com>

Prominent userspace - systemd - cannot handle watchdogs without
WDIOF_SETTIMEOUT, even if it was configured to the same time as the
driver selected or was used by firmware to start the watchdog. To avoid
failing in this case, implement a handler that only fails if a deviating
set_timeout is requested.

Signed-off-by: Jan Kiszka <jan.kiszka@...mens.com>
---

See also https://github.com/systemd/systemd/issues/20683

 drivers/watchdog/rti_wdt.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c
index 359302f71f7e..365255b15a0d 100644
--- a/drivers/watchdog/rti_wdt.c
+++ b/drivers/watchdog/rti_wdt.c
@@ -173,13 +173,27 @@ static unsigned int rti_wdt_get_timeleft_ms(struct watchdog_device *wdd)
 	return timer_counter;
 }
 
+static int rti_wdt_set_timeout(struct watchdog_device *wdd,
+			       unsigned int timeout)
+{
+	/*
+	 * Updating the timeout after start is actually not supported, but
+	 * let's ignore requests for the already configured value. Helps
+	 * existing userspace such as systemd.
+	 */
+	if (timeout != heartbeat)
+		return -EOPNOTSUPP;
+
+	return 0;
+}
+
 static unsigned int rti_wdt_get_timeleft(struct watchdog_device *wdd)
 {
 	return rti_wdt_get_timeleft_ms(wdd) / 1000;
 }
 
 static const struct watchdog_info rti_wdt_info = {
-	.options = WDIOF_KEEPALIVEPING,
+	.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT,
 	.identity = "K3 RTI Watchdog",
 };
 
@@ -187,6 +201,7 @@ static const struct watchdog_ops rti_wdt_ops = {
 	.owner		= THIS_MODULE,
 	.start		= rti_wdt_start,
 	.ping		= rti_wdt_ping,
+	.set_timeout	= rti_wdt_set_timeout,
 	.get_timeleft	= rti_wdt_get_timeleft,
 };
 
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ