[RndTbl] *reading* a file causes reboot

Trevor Cordes trevor at tecnopolis.ca
Mon May 4 23:23:20 CDT 2015


On 2015-05-04 Wyatt Zacharias wrote:
> Does your own system have /dev/watchdog? Mine does, but I'm in the
> middle of a bunch of stuff so I'm not going to go poking at it.

Ya, grep it for fun an profit!  Maybe quit all daemons first, and type
sync every 1s until it blows up.

> Also, did you read this:
> https://www.kernel.org/doc/Documentation/watchdog/watchdog-api.txt

Ya, I hadn't done the research yet.  I was trying to think the
philosophy through before delving into the details to find out why
someone thinks this is a feature, not a bug.

It appears this is the problem:

When the device is closed, the watchdog is disabled, unless the "Magic
Close" feature is supported (see below).
...
If a driver supports "Magic Close", the driver will not disable the
watchdog unless a specific magic character 'V' has been sent to
/dev/watchdog just before closing the file.  If the userspace daemon
closes the file without sending this special character, the driver
will assume that the daemon (and userspace in general) died, and will
stop pinging the watchdog without disabling it first.  This will then
cause a reboot if the watchdog is not re-opened in sufficient time.
=====

That's almost certainly what is happening.  I think the drive, if it
can, should look at the type of open (read or write), and ignore the
reads.  An open-for-read + close should do nothing.  Right now it
appears the driver thinks open-for-read + close is the same as
open-for-write + close.

Again, it's a philosophy thing, and I see no reason why a read should
ever "do" an action other than obtain data (yes, possibly rewinding a
tape too, etc), especially a hard reset!

Forgetting all that, my first task is to find out why grep -D skip is
still opening the watchdog file at all...

On 2015-05-04 Adam Thompson wrote:
> I've found "find / -xdev -type f -print0 | xargs grep
> string /dev/null" to be completely reliable and reasonably portable.

Ya, that would work as long as I wasn't counting on separate fs's being
checked too (separate /home for instance); or just strike the -xdev.
That would make a good semi-universal alias.

Oh, and you forgot the -0 to xargs.  And probably want a /dev/null
after the grep too.


More information about the Roundtable mailing list