[PATCH] watchdog: Device must be opened for writing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If userspace opens the watchdog device self-feeding stops. Sometimes
opening the device happens by accident, e.g. by mistakenly running grep
recursively in a wrong directory which leads to the server being reset.

Watchdog device does not handle read operation therefore the issue can be
prevented by requiring the device to be opened for writing:

- Prevent opening the device without FMODE_WRITE

Signed-off-by: Stanislav German-Evtushenko <ginermail@xxxxxxxxx>
---
 drivers/watchdog/watchdog_dev.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 3bab32485273..28b88542a4d0 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -835,6 +835,10 @@ static int watchdog_open(struct inode *inode, struct file *file)
 	bool hw_running;
 	int err;
 
+	/* Must be open for writing */
+	if (!(file->f_mode & FMODE_WRITE))
+		return -EINVAL;
+
 	/* Get the corresponding watchdog device */
 	if (imajor(inode) == MISC_MAJOR)
 		wd_data = old_wd_data;

base-commit: cf813c67d9619fd474c785698cbed543b94209dd
-- 
2.25.1




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux