* Moving fasync_struct into struct file?
@ 2002-02-19 7:18 Rusty Russell
2002-02-19 9:11 ` Alan Cox
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Rusty Russell @ 2002-02-19 7:18 UTC (permalink / raw)
To: davem, kuznet, sfr; +Cc: linux-kernel
Hi guys,
Stephen Rothwell pointed out that if you set up SIGIO from an
fd, fork, and exit, and PIDs wrap, the new process may be clobbered by
the SIGIO. IMVHO the best way to clean this up is to check the
fasync_list in sys_close, and if pid == filp->f_owner.pid and fd ==
fasync_list->fa_fd, unregister the SIGIO.
This means we need a move the "struct fasync_struct
fasync_list" into struct file (up from all the subsystems which use
it, eg. struct socket).
See any problems with this?
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: Moving fasync_struct into struct file?
2002-02-19 7:18 Moving fasync_struct into struct file? Rusty Russell
@ 2002-02-19 9:11 ` Alan Cox
2002-02-19 19:17 ` kuznet
2002-02-19 10:40 ` Bob Dunlop
2002-02-19 19:08 ` kuznet
2 siblings, 1 reply; 8+ messages in thread
From: Alan Cox @ 2002-02-19 9:11 UTC (permalink / raw)
To: Rusty Russell; +Cc: davem, kuznet, sfr, linux-kernel
> the SIGIO. IMVHO the best way to clean this up is to check the
> fasync_list in sys_close, and if pid == filp->f_owner.pid and fd ==
> fasync_list->fa_fd, unregister the SIGIO.
We already clean up fasync structures on close, its the drivers
responsibility to do so. If you wanted to be more strict you could do
a similar helper call in the other closing callback for each fd close.
> This means we need a move the "struct fasync_struct
> fasync_list" into struct file (up from all the subsystems which use
> it, eg. struct socket).
Any reason for not just caching the 32bit task ident field ? Using the
slightly confusingly p->parent_exec_id, which is basically a 32bit process
ident for example
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Moving fasync_struct into struct file?
2002-02-19 9:11 ` Alan Cox
@ 2002-02-19 19:17 ` kuznet
2002-02-20 2:04 ` Alan Cox
0 siblings, 1 reply; 8+ messages in thread
From: kuznet @ 2002-02-19 19:17 UTC (permalink / raw)
To: Alan Cox; +Cc: rusty, davem, sfr, linux-kernel
Hello!
> We already clean up fasync structures on close,
We do not.
> responsibility to do so. If you wanted to be more strict you could do
> a similar helper call in the other closing callback for each fd close.
This is technical issue how to implement this exactly.
BTW, sed -e 's/more strict/not so buggy/' :-)
Alexey
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Moving fasync_struct into struct file?
2002-02-19 19:17 ` kuznet
@ 2002-02-20 2:04 ` Alan Cox
2002-02-20 19:13 ` kuznet
0 siblings, 1 reply; 8+ messages in thread
From: Alan Cox @ 2002-02-20 2:04 UTC (permalink / raw)
To: kuznet; +Cc: Alan Cox, rusty, davem, sfr, linux-kernel
> > We already clean up fasync structures on close,
> We do not.
Then fix your driver. All the drivers I looked at do stuff like this...
which seems to do the job nicely
static int close_pad(struct inode * inode, struct file * file)
{
lock_kernel();
fasync_pad(-1, file, 0);
if (!--active)
outb(0x30, current_params.io+2); /* switch off digitiser */
unlock_kernel();
return 0;
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Moving fasync_struct into struct file?
2002-02-19 7:18 Moving fasync_struct into struct file? Rusty Russell
2002-02-19 9:11 ` Alan Cox
@ 2002-02-19 10:40 ` Bob Dunlop
2002-02-19 19:08 ` kuznet
2 siblings, 0 replies; 8+ messages in thread
From: Bob Dunlop @ 2002-02-19 10:40 UTC (permalink / raw)
To: Rusty Russell; +Cc: davem, kuznet, sfr, linux-kernel
Hi,
On Tue, Feb 19, Rusty Russell wrote:
> This means we need a move the "struct fasync_struct
> fasync_list" into struct file (up from all the subsystems which use
> it, eg. struct socket).
>
> See any problems with this?
At first I thought I would clean up the drivers a little moving common
code from the release routine. The release code is not called in the
example you gave because of the fork, correct ?
Then I realised what happens if several processes all request SIGIO
notification on different descriptors. The driver still needs to keep
a private list of all the processes registered with it. struct file
should at best contain a pointer back to the relevant structure in the
driver private list for cleanup ?
--
Bob Dunlop
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: Moving fasync_struct into struct file?
2002-02-19 7:18 Moving fasync_struct into struct file? Rusty Russell
2002-02-19 9:11 ` Alan Cox
2002-02-19 10:40 ` Bob Dunlop
@ 2002-02-19 19:08 ` kuznet
2 siblings, 0 replies; 8+ messages in thread
From: kuznet @ 2002-02-19 19:08 UTC (permalink / raw)
To: Rusty Russell; +Cc: davem, sfr, linux-kernel
Hello!
> Stephen Rothwell pointed out that if you set up SIGIO from an
> fd, fork, and exit, and PIDs wrap, the new process may be clobbered by
> the SIGIO. IMVHO the best way to clean this up is to check the
> fasync_list in sys_close, and if pid == filp->f_owner.pid and fd ==
> fasync_list->fa_fd, unregister the SIGIO.
>
> This means we need a move the "struct fasync_struct
> fasync_list" into struct file (up from all the subsystems which use
> it, eg. struct socket).
>
> See any problems with this?
I do not see.
It is a long known piece of shit in the kernel crying about repair.
I remember Al Viro planned to do something with this for 2.4,
but this has been forgotten again.
Alexey
^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <E16d4XU-0003VI-00@wagner.rustcorp.com.au.suse.lists.linux.kernel>]
* Re: Moving fasync_struct into struct file?
[not found] <E16d4XU-0003VI-00@wagner.rustcorp.com.au.suse.lists.linux.kernel>
@ 2002-02-19 9:27 ` Andi Kleen
0 siblings, 0 replies; 8+ messages in thread
From: Andi Kleen @ 2002-02-19 9:27 UTC (permalink / raw)
To: Rusty Russell; +Cc: linux-kernel
Rusty Russell <rusty@rustcorp.com.au> writes:
> Hi guys,
>
> Stephen Rothwell pointed out that if you set up SIGIO from an
> fd, fork, and exit, and PIDs wrap, the new process may be clobbered by
> the SIGIO. IMVHO the best way to clean this up is to check the
> fasync_list in sys_close, and if pid == filp->f_owner.pid and fd ==
> fasync_list->fa_fd, unregister the SIGIO.
The pid/owner checking at setup time is very broken anyways. Consider a
threaded application that wants to set up SIGIO from one thread but receive
from another. It has to be root currently to do that.
Best would be to never check anything in F_SETOWN, but just save the
uid/pid/gid and always check at signal sending time.
[in addition sk->proc should go and use the fasync list, but that is a
different thing for now]
-Andi
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2002-02-20 19:15 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-19 7:18 Moving fasync_struct into struct file? Rusty Russell
2002-02-19 9:11 ` Alan Cox
2002-02-19 19:17 ` kuznet
2002-02-20 2:04 ` Alan Cox
2002-02-20 19:13 ` kuznet
2002-02-19 10:40 ` Bob Dunlop
2002-02-19 19:08 ` kuznet
[not found] <E16d4XU-0003VI-00@wagner.rustcorp.com.au.suse.lists.linux.kernel>
2002-02-19 9:27 ` Andi Kleen
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®