From: Al Viro <viro@ZenIV.linux.org.uk>
To: Wim Van Sebroeck <wim@iguana.be>
Cc: linux-watchdog@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: [RFC] watchdog ->release() races
Date: Tue, 7 May 2013 21:10:01 +0100 [thread overview]
Message-ID: <20130507201001.GR25399@ZenIV.linux.org.uk> (raw)
Watchdog drivers tend to do something like that:
foo_open()
{
if (test_and_set_bit(0, &foo_is_open))
return -EBUSY;
...
}
foo_write()
{
...
assign foo_expect_close
...
}
foo_release()
{
look at foo_expect_close, act accordingly
clear_bit(0, &foo_is_open);
foo_expect_close = 0;
}
OK, so it tries to make sure that there's only one opened struct file for
the device; fair enough, but what happens if we have
task A: open()/write()/close()
task B: open()/write()/close()
with task A losing CPU just between clear_bit() and clearing foo_expect_close?
If it regains CPU just after write() done by task B, we'll get foo_expect_close
unexpectedly cleared.
It's obviously racy; I'm not sure if we care about that race, but if we
do, there's about 80 drivers that need to be fixed...
Comments?
next reply other threads:[~2013-05-07 20:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-07 20:10 Al Viro [this message]
2013-05-07 21:00 ` [RFC] watchdog ->release() races Linus Torvalds
2013-05-07 21:17 ` Al Viro
2013-05-08 0:30 ` Guenter Roeck
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=20130507201001.GR25399@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=linux-watchdog@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=wim@iguana.be \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.