linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Waiman Long <longman@redhat.com>
Cc: Boqun Feng <boqun.feng@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Dmitry Vyukov <dvyukov@google.com>,
	syzbot <syzbot+a9fb1457d720a55d6dc5@syzkaller.appspotmail.com>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	allison@lohutok.net, areber@redhat.com,
	aubrey.li@linux.intel.com, Andrei Vagin <avagin@gmail.com>,
	Bruce Fields <bfields@fieldses.org>,
	Christian Brauner <christian@brauner.io>,
	cyphar@cyphar.com, "Eric W. Biederman" <ebiederm@xmission.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	guro@fb.com, Jeff Layton <jlayton@kernel.org>,
	Joel Fernandes <joel@joelfernandes.org>,
	Kees Cook <keescook@chromium.org>,
	linmiaohe@huawei.com,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Michal Hocko <mhocko@suse.com>, Ingo Molnar <mingo@kernel.org>,
	Oleg Nesterov <oleg@redhat.com>,
	sargun@sargun.me,
	syzkaller-bugs <syzkaller-bugs@googlegroups.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: possible deadlock in send_sigio
Date: Mon, 15 Jun 2020 13:40:46 -0700	[thread overview]
Message-ID: <20200615204046.GW8681@bombadil.infradead.org> (raw)
In-Reply-To: <0c854a69-9b89-9e45-f2c1-e60e2a9d3f1c@redhat.com>

On Mon, Jun 15, 2020 at 01:13:51PM -0400, Waiman Long wrote:
> On 6/15/20 12:49 PM, Matthew Wilcox wrote:
> > On Fri, Jun 12, 2020 at 03:01:01PM +0800, Boqun Feng wrote:
> > > On the archs using QUEUED_RWLOCKS, read_lock() is not always a recursive
> > > read lock, actually it's only recursive if in_interrupt() is true. So
> > > change the annotation accordingly to catch more deadlocks.
> > [...]
> > 
> > > +#ifdef CONFIG_LOCKDEP
> > > +/*
> > > + * read_lock() is recursive if:
> > > + * 1. We force lockdep think this way in selftests or
> > > + * 2. The implementation is not queued read/write lock or
> > > + * 3. The locker is at an in_interrupt() context.
> > > + */
> > > +static inline bool read_lock_is_recursive(void)
> > > +{
> > > +	return force_read_lock_recursive ||
> > > +	       !IS_ENABLED(CONFIG_QUEUED_RWLOCKS) ||
> > > +	       in_interrupt();
> > > +}
> > I'm a bit uncomfortable with having the _lockdep_ definition of whether
> > a read lock is recursive depend on what the _implementation_ is.
> > The locking semantics should be the same, no matter which architecture
> > you're running on.  If we rely on read locks being recursive in common
> > code then we have a locking bug on architectures which don't use queued
> > rwlocks.
> > 
> > I don't know whether we should just tell the people who aren't using
> > queued rwlocks that they have a new requirement or whether we should
> > say that read locks are never recursive, but having this inconsistency
> > is not a good idea!
> 
> Actually, qrwlock is more restrictive. It is possible that systems with
> qrwlock may hit deadlock which doesn't happens in other systems that use
> recursive rwlock. However, the current lockdep code doesn't detect those
> cases.

Oops.  I misread.  Still, my point stands; we should have the same
definition of how you're allowed to use locks from the lockdep point of
view, even if the underlying implementation won't deadlock on a particular
usage model.


So I'd be happy with:

+	return lockdep_pretend_in_interrupt || in_interrupt();

to allow the test-suite to test that it works as expected, without
actually disabling interrupts while the testsuite runs.


  reply	other threads:[~2020-06-15 20:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-04  5:55 possible deadlock in send_sigio syzbot
2020-06-11  2:32 ` Waiman Long
2020-06-11  7:43   ` Dmitry Vyukov
2020-06-11 13:51     ` Waiman Long
2020-06-11 14:22       ` Peter Zijlstra
2020-06-11 16:09         ` Waiman Long
2020-06-11 23:55           ` Boqun Feng
2020-06-12  1:55             ` Waiman Long
2020-06-12  7:01             ` Boqun Feng
2020-06-15 16:37               ` Waiman Long
2020-06-15 16:49               ` Matthew Wilcox
2020-06-15 17:13                 ` Waiman Long
2020-06-15 20:40                   ` Matthew Wilcox [this message]
2020-06-16  0:13                     ` Boqun Feng
2020-06-16  0:31                       ` Waiman Long
2020-06-11 16:07   ` Eric W. Biederman

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=20200615204046.GW8681@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=allison@lohutok.net \
    --cc=areber@redhat.com \
    --cc=aubrey.li@linux.intel.com \
    --cc=avagin@gmail.com \
    --cc=bfields@fieldses.org \
    --cc=boqun.feng@gmail.com \
    --cc=christian@brauner.io \
    --cc=cyphar@cyphar.com \
    --cc=dvyukov@google.com \
    --cc=ebiederm@xmission.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=guro@fb.com \
    --cc=jlayton@kernel.org \
    --cc=joel@joelfernandes.org \
    --cc=keescook@chromium.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mhocko@suse.com \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sargun@sargun.me \
    --cc=syzbot+a9fb1457d720a55d6dc5@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    /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 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).