public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* ->pid in dnotify
@ 2003-08-28 18:46 Ulrich Drepper
  2003-08-28 22:44 ` Jamie Lokier
  0 siblings, 1 reply; 2+ messages in thread
From: Ulrich Drepper @ 2003-08-28 18:46 UTC (permalink / raw)
  To: Linus Torvalds, Andrew Morton, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 933 bytes --]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm not entirely sure about this change.  But it seems to be necessary.
 The dnotify code stores the PID in the file structure.  The entire
process shares the file and any signal (is it used for that?) should be
sent to the process (thread group), not the individual thread.  Also
keep in mind that threads can go away while the process (and therefore
file descriptor) remain.  And the ID of the thread can be reused.

Somebody who knows this code should take a good look.

- --
- --------------.                        ,-.            444 Castro Street
Ulrich Drepper \    ,-----------------'   \ Mountain View, CA 94041 USA
Red Hat         `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE/Tk4T2ijCOnn/RHQRAh5cAJkBTNx7g9pj+naBm5fyftI9LatRTACfaPkg
t/ZzWXPAjlaqRJc+wIRP8AU=
=x8G3
-----END PGP SIGNATURE-----

[-- Attachment #2: d-dnotify-pid --]
[-- Type: text/plain, Size: 292 bytes --]

--- linux/fs/dnotify.c-save	2003-04-03 10:04:03.000000000 -0800
+++ linux/fs/dnotify.c	2003-08-28 11:41:23.000000000 -0700
@@ -94,7 +94,7 @@
 		prev = &odn->dn_next;
 	}
 
-	error = f_setown(filp, current->pid, 1);
+	error = f_setown(filp, current->tgid, 1);
 	if (error)
 		goto out_free;
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: ->pid in dnotify
  2003-08-28 18:46 ->pid in dnotify Ulrich Drepper
@ 2003-08-28 22:44 ` Jamie Lokier
  0 siblings, 0 replies; 2+ messages in thread
From: Jamie Lokier @ 2003-08-28 22:44 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Linus Torvalds, Andrew Morton, linux-kernel

Ulrich Drepper wrote:
> Also keep in mind that threads can go away while the process (and
> therefore file descriptor) remain.  And the ID of the thread can be
> reused

The problem of owner churn goes beyond threads - fds can be passed to
other process and outlive the original thread or process which created
them.  Changing ->pid to ->tgid doesn't fix this.

Using ->tgid in dnotify is at least consistent with fcntl_setlease()
in locks.c, and the call to f_setown() in futex.c.

Unfortunately I can think of a few situations where you would want the
signal delivered to one thread, but none where you'd want it delivered
to a whole process (same for dnotify and setlease).

Userspace can change the pid straight after to ->pid using
fcntl(fd,F_SETOWN,...), but that leaves a time window where a thread
creates a dnotify or lease, and the signal will be delivered
process-wide until the thread can direct it to itself.

-- Jamie

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-08-28 22:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-28 18:46 ->pid in dnotify Ulrich Drepper
2003-08-28 22:44 ` Jamie Lokier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox