From: daw@cs.berkeley.edu (David Wagner)
To: linux-kernel@vger.kernel.org
Subject: Re: [RFC/PATCH] revoke/frevoke system calls V2
Date: Mon, 7 Aug 2006 22:52:59 +0000 (UTC) [thread overview]
Message-ID: <eb8g8b$837$1@taverner.cs.berkeley.edu> (raw)
In-Reply-To: 20060807224144.3bb64ac4.froese@gmx.de
Edgar Toernig wrote:
>Your implementation is much cruder - it simply takes the fd
>away from the app; any future use gives EBADF. As a bonus,
>it works for regular files and even goes as far as destroying
>all mappings of the file from all processes (even root processes).
>IMVHO this is a disaster from a security and reliability point
>of view.
I'm still trying to understand the semantics of this proposed
frevoke() implementation. Can an attacker use this to forcibly
close some other processes' file descriptor? Suppose the target
process has fd 0 open and the attacker revokes the file corresponding
to fd 0; what is the state of fd 0 in the target process? Is it
closed? If the target process then open()s another file, does it
get bound to fd 0? (Recall that open() always binds to the lowest
unused fd.) If the answers are "yes", then the security consequences
seem very scary.
For example, suppose that the attacker opens some file onto fd 2,
forks and execs /bin/login (say), and revokes that fd while /bin/login
is in the middle of executing. Can this cause horrible catastrophes?
Note that, to defend against stderr attacks, some setuid programs will
forcibly open /dev/zero three times to make sure that fds 0, 1, and
2 are open, so that opening some later file (e.g., /etc/passwd)
doesn't inadvertently get attached to fd 2. If some other process
can forcibly close /bin/login's fd 2, then that's very bad.
Can something like the following happen?
Attacker /bin/login
-------- ----------
open("foo") -> 2
fork()
exec("/bin/login")
open("/dev/zero") -> 3
open("/dev/zero") -> 4
open("/dev/zero") -> 5
frevoke(2)
open("/etc/passwd") -> 2
...
perror("wrong password") # Corrupts /etc/passwd!
/* A hypothetical implementation of /bin/login: */
int main() {
// Protect ourselves from stderr attacks
int ignore;
ignore = open("/dev/zero");
ignore = open("/dev/zero");
ignore = open("/dev/zero");
int pwfd;
pwfd = open("/etc/passwd", O_RDWR);
...
if (!correctpassword(uname, pass)) {
perror("wrong password");
exit(1);
}
...
}
next prev parent reply other threads:[~2006-08-07 22:53 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-27 14:25 [RFC/PATCH] revoke/frevoke system calls V2 Pekka J Enberg
2006-07-27 15:07 ` Alan Cox
2006-07-27 15:33 ` Pekka Enberg
2006-07-27 16:09 ` Alan Cox
2006-07-27 16:01 ` Pekka J Enberg
2006-07-27 16:30 ` Alan Cox
2006-07-27 17:07 ` Pekka J Enberg
2006-07-27 18:27 ` Pekka Enberg
2006-07-27 16:41 ` Ulrich Drepper
2006-07-27 17:05 ` Pekka J Enberg
2006-07-27 17:13 ` Ulrich Drepper
2006-07-27 17:33 ` H. Peter Anvin
2006-07-27 17:44 ` Ulrich Drepper
2006-07-27 18:00 ` H. Peter Anvin
2006-07-27 17:33 ` Alan Cox
2006-07-27 17:33 ` O_CAREFUL flag to disable open() side effects H. Peter Anvin
2006-07-27 17:43 ` Russell King
2006-07-27 17:50 ` Ulrich Drepper
2006-07-27 18:05 ` Alan Cox
2006-07-27 18:03 ` H. Peter Anvin
2006-07-27 18:14 ` Joshua Hudson
2006-08-05 21:05 ` [RFC/PATCH] revoke/frevoke system calls V2 Pavel Machek
2006-07-27 18:06 ` Petr Baudis
2006-07-27 18:10 ` Pekka Enberg
2006-07-27 19:30 ` Horst H. von Brand
2006-07-28 3:40 ` Pekka J Enberg
2006-07-27 18:34 ` Alan Cox
2006-08-05 12:29 ` Pavel Machek
2006-08-07 5:42 ` Pekka J Enberg
2006-08-07 8:17 ` Edgar Toernig
2006-08-07 9:51 ` Pekka Enberg
2006-08-07 20:41 ` Edgar Toernig
2006-08-07 22:24 ` Chase Venters
2006-08-08 12:15 ` Alan Cox
2006-08-09 8:41 ` Edgar Toernig
2006-08-09 10:39 ` Alan Cox
2006-08-09 18:00 ` Edgar Toernig
2006-08-09 18:36 ` Alan Cox
2006-08-09 19:13 ` Pekka Enberg
2006-08-09 20:08 ` Edgar Toernig
2006-08-09 21:29 ` Edgar Toernig
2006-08-11 7:52 ` Helge Hafting
2006-08-07 22:52 ` David Wagner [this message]
2006-08-07 22:56 ` Daniel Jacobowitz
2006-08-07 23:12 ` Chase Venters
2006-08-08 12:16 ` Pekka Enberg
2006-08-08 16:02 ` Kari Hurtta
2006-08-08 21:54 ` Theodore Tso
2006-08-09 6:32 ` Pekka Enberg
2006-08-08 12:13 ` Alan Cox
2006-08-08 12:29 ` Alan Cox
2006-08-08 12:31 ` Pekka Enberg
2006-08-08 12:57 ` Pavel Machek
2006-08-08 14:14 ` Alan Cox
2006-08-08 13:57 ` Pavel Machek
2006-08-09 8:41 ` Edgar Toernig
2006-08-09 10:42 ` Alan Cox
2006-08-09 18:00 ` Edgar Toernig
2006-08-09 18:35 ` Alan Cox
2006-08-09 19:14 ` Pekka Enberg
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='eb8g8b$837$1@taverner.cs.berkeley.edu' \
--to=daw@cs.berkeley.edu \
--cc=daw-usenet@taverner.cs.berkeley.edu \
--cc=linux-kernel@vger.kernel.org \
/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