Messages in this thread |  | | Date | Sat, 19 May 2001 18:41:39 +0200 (MET DST) | From | Andries.Brouwer@cwi ... | Subject | Re: Why side-effects on open(2) are evil. (was Re: [RFD w/info-PATCH] device arguments from lookup) |
| |
>> Opening device files often has interesting side effects.
> Too bad. They can be triggered by similar races between attacker > changing the type of object (file<->symlink) and backup.
Yes. This is a well-known security problem. Doing stat("file", &s); if (action desired) { action("file"); } is no good because there is a race. But doing fd = open("file", flags); fstat(fd, &s); if (action desired) { f_action(fd); } is no good either because the open() has unknown side effects. It helps to add flags like O_NONBLOCK and perhaps O_NOCTTY, but that is not quite good enough.
One would like to have a version of the open() call that was guaranteed free of side effects, and gave a fd only - perhaps for stat(), perhaps for ioctl(). This guarantee could perhaps be obtained by omitting the f->f_op->open(inode,f); call in dentry_open() when the open call is open("file", O_FDONLY); Of course it may be that we afterwards decide that fd must be used, and then it needs upgrading: fd = f_open(fd, O_RDWR);
Andries
[Such a construction allows various cleanups. But no doubt it has problems that I have not yet thought of.] - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|  |