Re: Security question: "Text file busy" overwriting executables but no

Kai Henningsen (kaih@khms.westfalen.de)
14 Oct 2001 14:57:00 +0200


torvalds@transmeta.com (Linus Torvalds) wrote on 13.10.01 in <Pine.LNX.4.33.0110130956350.8707-100000@penguin.transmeta.com>:

> Now, somebody who _isn't_ stupid (and that, of course, is me), immediately
> goes "well, _duh_, why don't you speed up read() instead?".

Probably because people think that's hard ... so they invent another thing
that's even harder.

> The fact is, all the problems that "MAP_COPY" has just go away if you
> instead of thinking about a mmap(), you think about doing a "read()" and
> just marking the pages PAGE_COPY if they are exclusive.

That's part of the problem. The other is the idea that mmap only needs to
read those pages actually needed.

Hmm.

Would it be possible - and cheap enough - to do this optimization:

When read()ing a file, *if* nobody else has that inode open (which is
probably impossible to determine with networked filesystems, so one would
probably have to exclude those), create mmap-like mappings where possible
without actually reading the pages; at the moment someone else opens the
file, actually read them in and mark them PAGE_COPY.

Or maybe just do it exclusive of writers, not readers.

(I don't think waiting for actual writes would be sensible.)

MfG Kai
-
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/