All of lore.kernel.org
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org,
	linux RAID <linux-raid@vger.kernel.org>,
	majianpeng <majianpeng@gmail.com>,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] md / procfs: avoid Oops if md-mod removed while /proc/mdstat is being polled.
Date: Mon, 3 Mar 2014 14:53:33 +1100	[thread overview]
Message-ID: <20140303145333.05ce4315@notabene.brown> (raw)
In-Reply-To: <20140227153242.42cb9b9ef83dacc895017d44@linux-foundation.org>

[-- Attachment #1: Type: text/plain, Size: 2709 bytes --]

On Thu, 27 Feb 2014 15:32:42 -0800 Andrew Morton <akpm@linux-foundation.org>
wrote:

> On Fri, 28 Feb 2014 10:07:57 +1100 NeilBrown <neilb@suse.de> wrote:
> 
> > On Thu, 27 Feb 2014 13:51:25 -0800 Andrew Morton <akpm@linux-foundation.org>
> > wrote:
> > 
> > > On Fri, 28 Feb 2014 08:34:43 +1100 NeilBrown <neilb@suse.de> wrote:
> > > 
> > > > On Thu, 27 Feb 2014 12:58:07 -0800 Andrew Morton <akpm@linux-foundation.org>
> > > > wrote:
> > > > 
> > > > > On Thu, 27 Feb 2014 17:24:45 +1100 NeilBrown <neilb@suse.de> wrote:
> > > > > 
> > > > > > If poll or select is waiting on /proc/mdstat when md-mod is unloaded
> > > > > > an oops will ensure when the poll/select completes.
> > > > > > 
> > > > > > This is because the wait_queue_head which is registered with poll_wait()
> > > > > > is local to the module and no longer exists when the poll completes and
> > > > > > detaches that wait_queue_head (in poll_free_wait -> remove_wait_queue).
> > > > > > 
> > > > > > To fix this we need the wait_queue_head to have (at least) the same life
> > > > > > time as the proc_dir_entry.  So this patch places it in that structure.
> > > > > > 
> > > > > > We:
> > > > > >   - add pde_poll_wait to struct proc_dir_entry
> > > > > >   - call poll_wait() passing this when poll() is called on the proc file
> > > > > >   - export a function proc_wake_up which will call wake_up() on pde_poll_wait
> > > > > > 
> > > > > > and make use of all that in md.c
> > > > > 
> > > > > This sounds wrong.  If a userspace process is waiting on
> > > > > md_event_waiters then the md module is "busy" and the rmmod attempt
> > > > > should fail?
> > > > 
> > > > Al Viro says "no" quite firmly.
> > > > 
> > > > I think the core argument is that
> > > > 
> > > >   rmmod md-mod < /proc/mdstat
> > > > 
> > > > would deadlock.
> > > 
> > > Well, only if the rmmod hangs around waiting for the module to go idle.
> > > I'm thinking rmmod should fail.  EBUSY.
> 
> This?  What happens if we just fail the rmmod when the module is busy
> (which it is).

I was hoping that Al would step in with an answer, but I got impatient had
had a look around myself.

I found

commit 99b76233803beab302123d243eea9e41149804f3
Author: Alexey Dobriyan <adobriyan@gmail.com>
Date:   Wed Mar 25 22:48:06 2009 +0300

    proc 2/2: remove struct proc_dir_entry::owner
    


which references

https://bugzilla.kernel.org/show_bug.cgi?id=12454

which seems to suggest that we used to try to do as you suggest but it was
racy and would be a lot of work to "fix". The chosen solution was to only
'get' the module during read/write, not just while the /proc file is open.

NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

      reply	other threads:[~2014-03-03  3:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-27  6:24 [PATCH] md / procfs: avoid Oops if md-mod removed while /proc/mdstat is being polled NeilBrown
2014-02-27 20:58 ` Andrew Morton
2014-02-27 21:34   ` NeilBrown
2014-02-27 21:51     ` Andrew Morton
2014-02-27 23:07       ` NeilBrown
2014-02-27 23:32         ` Andrew Morton
2014-03-03  3:53           ` NeilBrown [this message]

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=20140303145333.05ce4315@notabene.brown \
    --to=neilb@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=majianpeng@gmail.com \
    --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 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.