From: BlaisorBlade <blaisorblade_spam@yahoo.it>
To: Andrew Morton <akpm@osdl.org>, Linus Torvalds <torvalds@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Missing BKL in sys_chroot() for 2.6
Date: Sun, 6 Jun 2004 19:58:48 +0200 [thread overview]
Message-ID: <200406061958.48262.blaisorblade_spam@yahoo.it> (raw)
(PLEASE cc me on replies as I'm not subscribed).
Set_fs_root *claims* it wants the BKL held:
/*
* Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
* It can block. Requires the big lock held.
*/
void set_fs_root(struct fs_struct *fs, struct vfsmount *mnt,
struct dentry *dentry)
But sys_chroot ignores this. So I attach this patch (apply with patch -p1 -l).
Maybe the solution is to kill that comment, maybe not (sys_pivot_root() calls
chroot_fs_refs() -> set_fs_root() with the BKL held, but that has a lot of
reasons other than this). If that comment is correct, however, it probably
holds even for set_fs_altroot(), since it's similar. So this patch adds it.
TESTING: none, I'm sure about the inconsistency, a lot less about the solution
(no kernel manual explains the BKL, since it is a relict; except the ones who
still says it blocks all the rest of the kernel, while I think it is just a
recursive and "sleepable" spinlock - am I correct?).
--- vanilla-linux-2.6.6/fs/open.c.saved 2004-05-10 21:37:11.000000000 +0200
+++ vanilla-linux-2.6.6/fs/open.c 2004-06-06 19:40:20.000000000 +0200
@@ -581,8 +581,13 @@
if (!capable(CAP_SYS_CHROOT))
goto dput_and_out;
+ lock_kernel();
+
set_fs_root(current->fs, nd.mnt, nd.dentry);
set_fs_altroot();
+
+ unlock_kernel();
+
error = 0;
dput_and_out:
path_release(&nd);
--- vanilla-linux-2.6.6/fs/namei.c.saved 2004-05-10 21:37:09.000000000
+0200
+++ vanilla-linux-2.6.6/fs/namei.c 2004-06-06 19:49:25.000000000 +0200
@@ -814,6 +814,9 @@
return 1;
}
+/*
+ * Requires the big lock held.
+ */
void set_fs_altroot(void)
{
char *emul = __emul_prefix();
--
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729
next reply other threads:[~2004-06-07 17:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-06 17:58 BlaisorBlade [this message]
2004-06-07 18:56 ` Linus Torvalds
2004-06-07 19:13 ` Phy Prabab
2004-06-07 19:18 ` Linus Torvalds
2004-06-07 19:33 ` Phy Prabab
2004-06-07 22:53 ` viro
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=200406061958.48262.blaisorblade_spam@yahoo.it \
--to=blaisorblade_spam@yahoo.it \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/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
all inboxes | Powered by JetHome®