Re: VFS?VM - mmap/write deadlock

Linus Torvalds (torvalds@transmeta.com)
Tue, 21 Dec 1999 01:10:36 -0800 (PST)


On Mon, 20 Dec 1999, Linus Torvalds wrote:
>
> Ok, I think that was the solution I remember, but it's obviously broken.
> It leaves a window of non-updated page contents that can be read. Ho
> humm.. Your suggestion may be the way to go.

Actually, a less intrusive but fairly cheesy fix is to just do a simple
read of the first and the last byte of the source before locking the
destination page.

That means that the source will be brought in (which we have to do
anyway), and for the degenerate case of source == dest we just magically
avoided the special case because of the "up-to-date overrides the need for
lock on a read" rule.

Works, is simple, and is just _extremely_ cheesy.

The "notice the recursion and SIGBUS" solution would work too, but has
more special code. The main downside to it is that there isn't really
anything WRONG with modifying a file by doing a "write()" from a mmap'ed
region - it's a silly thing to do (and because the write() is a "memcpy()"
instead of a "memmove()" you have undefined behaviour for the overlapping
case), but it is not necessarily something that should cause a SIGBUS.

Does anybody have any non-cheezy suggestions?

Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/