From: Andrey Borzenkov <arvidjaar@mail.ru>
To: devfs@oss.sgi.com
Cc: linux-kernel@vger.kernel.org,
Thierry Vignaud <tvignaud@mandrakesoft.com>,
Andrew Morton <akpm@osdl.org>
Subject: [PATCH][2.5.75] devfsd hangs on restart - is_devfsd_or_child() problem
Date: Sat, 12 Jul 2003 14:11:41 +0400 [thread overview]
Message-ID: <200307121411.41131.arvidjaar@mail.ru> (raw)
In-Reply-To: <200307112247.12646.arvidjaar@mail.ru>
[-- Attachment #1: Type: text/plain, Size: 1335 bytes --]
On Friday 11 July 2003 22:47, Andrey Borzenkov wrote:
> I cannot believe it is so fragile ...
>
> is_devfsd_or_child() simplemindedly checks for pgrp:
>
> static int is_devfsd_or_child (struct fs_info *fs_info)
> {
> if (current == fs_info->devfsd_task) return (TRUE);
> if (current->pgrp == fs_info->devfsd_pgrp) return (TRUE);
> return (FALSE);
> } /* End Function is_devfsd_or_child */
>
Andrew, one more for your collection :)
The code that did proper check existed in 2.4 and was removed in 2.5 for
whatever reason. The patch restores it slightly modified as below.
2.4 code looks somewhat unclean in that
- it traverses task list without lock.
- is starts from current->real_parent but nothing prevents current be
init_task itself. This hung for me on 2.5 during boot. May be 2.4 does
something differently.
Comments?
regards
-andrey
This is trivially reproduced under 2.5 by using devfsd.conf lines
LOOKUP ^foo$ EXECUTE /home/bor/tmp/devfsd/handler /dev/bar
LOOKUP ^bar$ EXECUTE /home/bor/tmp/devfsd/handler /dev/foo
and handler like
-------- cut here ----------
#include <unistd.h>
int
main(int argc, char **argv, char **envp)
{
if (argc <= 1)
return 0;
setpgrp();
return access(argv[1], R_OK);
}
-------- cut here ----------
and doing ls /dev/foo
[-- Attachment #2: 2.5.75-is_devfsd_or_child.patch --]
[-- Type: text/x-diff, Size: 1023 bytes --]
--- linux-2.5.75-smp/fs/devfs/base.c.devfsd_child 2003-07-11 19:41:46.000000000 +0400
+++ linux-2.5.75-smp/fs/devfs/base.c 2003-07-12 13:51:49.000000000 +0400
@@ -676,6 +676,7 @@
#include <linux/smp.h>
#include <linux/version.h>
#include <linux/rwsem.h>
+#include <linux/sched.h>
#include <asm/uaccess.h>
#include <asm/io.h>
@@ -1325,8 +1326,20 @@ static void free_dentry (struct devfs_en
static int is_devfsd_or_child (struct fs_info *fs_info)
{
- if (current == fs_info->devfsd_task) return (TRUE);
- if (current->pgrp == fs_info->devfsd_pgrp) return (TRUE);
+ struct task_struct *p = current;
+
+ if (p == fs_info->devfsd_task) return (TRUE);
+ if (p->pgrp == fs_info->devfsd_pgrp) return (TRUE);
+ read_lock(&tasklist_lock);
+ for ( ; p != &init_task; p = p->real_parent)
+ {
+ if (p == fs_info->devfsd_task)
+ {
+ read_unlock (&tasklist_lock);
+ return (TRUE);
+ }
+ }
+ read_unlock (&tasklist_lock);
return (FALSE);
} /* End Function is_devfsd_or_child */
prev parent reply other threads:[~2003-07-12 9:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-11 18:47 Andrey Borzenkov
2003-07-12 10:11 ` Andrey Borzenkov [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=200307121411.41131.arvidjaar@mail.ru \
--to=arvidjaar@mail.ru \
--cc=akpm@osdl.org \
--cc=devfs@oss.sgi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tvignaud@mandrakesoft.com \
/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®