devfs
[Top] [All Lists]

[PATCH][2.5.75] devfsd hangs on restart - is_devfsd_or_child() problem

To: devfs@xxxxxxxxxxx
Subject: [PATCH][2.5.75] devfsd hangs on restart - is_devfsd_or_child() problem
From: Andrey Borzenkov <arvidjaar@xxxxxxx>
Date: Sat, 12 Jul 2003 14:11:41 +0400
Cc: linux-kernel@xxxxxxxxxxxxxxx, Thierry Vignaud <tvignaud@xxxxxxxxxxxxxxxx>, Andrew Morton <akpm@xxxxxxxx>
In-reply-to: <200307112247.12646.arvidjaar@mail.ru>
References: <200307112247.12646.arvidjaar@mail.ru>
Sender: devfs-bounce@xxxxxxxxxxx
User-agent: KMail/1.5
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.5.75-is_devfsd_or_child.patch
Description: Text Data

<Prev in Thread] Current Thread [Next in Thread>