linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Stanislav German-Evtushenko <ginermail@gmail.com>
Cc: Wim Van Sebroeck <wim@linux-watchdog.org>,
	linux-watchdog@vger.kernel.org
Subject: Re: [PATCH] watchdog: Device must be opened for writing
Date: Sat, 14 Aug 2021 12:56:46 -0700	[thread overview]
Message-ID: <20210814195646.GB3951799@roeck-us.net> (raw)
In-Reply-To: <20210814191345.27221-1-ginermail@gmail.com>

On Sun, Aug 15, 2021 at 04:13:45AM +0900, Stanislav German-Evtushenko wrote:
> 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@gmail.com>

NACK. That would be a major undocumented ABI change. Opening /dev/watchdog
for reading can be and is used today to test a watchdog.

Guenter

> ---
>  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
> 

  reply	other threads:[~2021-08-14 19:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-14 19:13 Stanislav German-Evtushenko
2021-08-14 19:56 ` Guenter Roeck [this message]
     [not found]   ` <CAPeRZrV+HwdmBKFB3tmG_tEHjsR8h3WLxKQYGDLOLgw178oq=A@mail.gmail.com>
2021-08-15  1:33     ` Guenter Roeck
2021-08-15  4:32       ` Stanislav German-Evtushenko

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=20210814195646.GB3951799@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=ginermail@gmail.com \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=wim@linux-watchdog.org \
    --subject='Re: [PATCH] watchdog: Device must be opened for writing' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).