public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* How to lock current->signal->tty
@ 2006-08-08 15:17 Alan Cox
  2006-08-08 15:10 ` Arjan van de Ven
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Alan Cox @ 2006-08-08 15:17 UTC (permalink / raw)
  To: linux-kernel, davem, sds, jack, dwmw2, tony.luck, jdike,
	James.Bottomley

The biggest crawly horror I've found so far in auditing the tty locking
is current->signal->tty. The tty layer currently and explicitly protects
this using tty_mutex. The core kernel likewise knows about this.

Unfortunately:
	SELinux doesn't do any locking at all
	Dquot passes the tty to tty_write_message without locking
	audit_log_exit doesn't do any locking at all
	acct.c thinks tasklist_lock protects it (wrong)
	drivers/char/sx misuses it unlocked in debug info
	fs/proc/array thinks tasklist_lock will save it (also wrong)
	fs3270 does fascinating things with it which don't look safe
	ebtables remote debugging (#if 0 thankfully) does no locking
		and just for fun calls the tty driver directly with no
		driver locking either.
	voyager_thread sets up a thread and then touches ->tty unlocked
		(and it seems daemonize already fixed it)
	Sparc solaris_procids sets it to NULL without locking
	arch/ia64/kernel/unanligned seems to write to it without locking
	arch/um/kernel/exec.c appears to believe task_lock is used

The semantics are actually as follows

signal->tty must not be changed without holding tty_mutex
signal->tty must not be used unless tty_mutex is held from before
reading it to completing using it
Simple if(signal->tty == NULL) type checks are ok

I'm looking longer term at tty ref counting and the like but for now and
current distributions it might be an idea to fix the existing problems.

Alan


^ permalink raw reply	[flat|nested] 18+ messages in thread
* Re: How to lock current->signal->tty
@ 2006-08-09  4:01 Albert Cahalan
  0 siblings, 0 replies; 18+ messages in thread
From: Albert Cahalan @ 2006-08-09  4:01 UTC (permalink / raw)
  To: sds, alan, linux-kernel, davem, viro

Stephen Smalley writes:

> SELinux is just revalidating access to the tty when the task
> changes contexts upon execve, and resetting the tty if the
> task is no longer allowed to use it.  Likewise with the open
> file descriptors that would be inherited.  No clearing of the
> ttys of other tasks required as far as SELinux is concerned,
> although that might not fit with normal semantics.

If the process goes back to the old context after a second
execve or via special rights, it ought regain access to the tty.

(just block access instead of resetting the tty)

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

end of thread, other threads:[~2006-08-13 21:33 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-08 15:17 How to lock current->signal->tty Alan Cox
2006-08-08 15:10 ` Arjan van de Ven
2006-08-08 15:44   ` Alan Cox
2006-08-08 16:41     ` Luck, Tony
2006-08-08 17:50       ` Alan Cox
2006-08-09  8:09         ` Jes Sorensen
2006-08-09 10:44           ` Alan Cox
2006-08-09 11:26             ` Jes Sorensen
2006-08-09 16:24             ` Luck, Tony
2006-08-09 18:10               ` Jes Sorensen
2006-08-08 22:06     ` Jan Kara
2006-08-08 17:11 ` Stephen Smalley
2006-08-08 17:43   ` Alan Cox
2006-08-08 17:44     ` Stephen Smalley
2006-08-08 18:10       ` Alan Cox
2006-08-08 20:02     ` Stephen Smalley
2006-08-13 21:34 ` Jan Kara
  -- strict thread matches above, loose matches on Subject: below --
2006-08-09  4:01 Albert Cahalan

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