public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Arkadiusz Miskiewicz <arekm@pld-linux.org>
Cc: linux-kernel@vger.kernel.org,
	"viro@parcelfarce.linux.theplanet.co.uk" 
	<viro@parcelfarce.linux.theplanet.co.uk>,
	James Morris <jmorris@redhat.com>,
	Stephen Smalley <sds@epoch.ncsc.mil>
Subject: Re: 2.6.0-test9 and sleeping function called from invalid context
Date: Sat, 25 Oct 2003 18:50:55 -0700	[thread overview]
Message-ID: <20031025185055.4d9273ae.akpm@osdl.org> (raw)
In-Reply-To: <200310260045.52094.arekm@pld-linux.org>

Arkadiusz Miskiewicz <arekm@pld-linux.org> wrote:
>
> Debug: sleeping function called from invalid context at 
>  include/asm/semaphore.h:119
>  in_atomic():1, irqs_disabled():0
>  Call Trace:
>   [<c011dfbb>] __might_sleep+0xab/0xf0
>   [<c019ed91>] inode_doinit_with_dentry+0x41/0x5d0
>   [<cf9b91b0>] bm_fill_super+0x0/0x40 [binfmt_misc]
>   [<c0170904>] d_instantiate+0x64/0x80
>   [<cf9b8f30>] bm_register_write+0x150/0x1d0 [binfmt_misc]
>   [<cf9b8de0>] bm_register_write+0x0/0x1d0 [binfmt_misc]
>   [<c01586ea>] vfs_write+0xca/0x140
>   [<c01587ff>] sys_write+0x3f/0x60
>   [<c010b37f>] syscall_call+0x7/0xb

Not nice.

fs/binfmt_misc.c:bm_register_write() is doing d_instantiate()
under a write_lock(), and the selinux d_instantiate() hook is
performing sleeping functions.

Now, we can just move the d_instantiate() call to outside the lock:

--- 25/fs/binfmt_misc.c~bm_register_write-locking-fix	2003-10-25 18:39:45.000000000 -0700
+++ 25-akpm/fs/binfmt_misc.c	2003-10-25 18:40:29.000000000 -0700
@@ -529,8 +529,8 @@ static ssize_t bm_register_write(struct 
 	inode->u.generic_ip = e;
 	inode->i_fop = &bm_entry_operations;
 
-	write_lock(&entries_lock);
 	d_instantiate(dentry, inode);
+	write_lock(&entries_lock);
 	list_add(&e->list, &entries);
 	write_unlock(&entries_lock);
 

which I think is OK, but the wider question would be: is the SELinux
d_instantiate callout allowed to sleep?  A quick audit seems to indicate
that it's OK, but only by luck I think.



  reply	other threads:[~2003-10-26  1:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-25 22:45 2.6.0-test9 and sleeping function called from invalid context Arkadiusz Miskiewicz
2003-10-26  1:50 ` Andrew Morton [this message]
2003-10-26  5:49   ` Andrew Morton
2003-10-26  8:26     ` viro
2003-10-26  8:41       ` Andrew Morton
2003-10-26  9:41         ` viro
2003-10-26 11:03         ` Manfred Spraul
2003-10-26 17:26           ` Manfred Spraul
2003-10-27 13:52     ` Stephen Smalley

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=20031025185055.4d9273ae.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=arekm@pld-linux.org \
    --cc=jmorris@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sds@epoch.ncsc.mil \
    --cc=viro@parcelfarce.linux.theplanet.co.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