Re: sys_write() racy for multi-threaded append?

From: Bodo Eggert
Date: Mon Mar 12 2007 - 03:54:29 EST


Michael K. Edwards <medwards.linux@xxxxxxxxx> wrote:

> On 3/8/07, Eric Dumazet <dada1@xxxxxxxxxxxxx> wrote:
>> Absolutely not. We dont want to slow down kernel 'just in case a fool might
>> want to do crazy things'
>
> Actually, I think it would make the kernel (negligibly) faster to bump
> f_pos before the vfs_write() call.

This is a security risk.

----------------
other process:
unlink(secrest_file)

Thread 1:
write(fd, large)
(interrupted)

Thread 2:
fseek(fd, -n, relative)
read(fd, buf)
----------------

BTW: The best thing you can do to a program where two threads race for
writing one fd is to let it crash and burn in the most spectacular way
allowed without affecting the rest of the system, unless it happens to
be a pipe and the number of bytes written is less than PIPE_MAX.
--
The secret of the universe is #@*%! NO CARRIER

Friß, Spammer: dyIw3Rs@xxxxxxxxxxxxxxxxxxxx PLxmr@xxxxxxxxxxxxxxxxxxxxx
HmiJuSaiuF@xxxxxxxxxxxxxxxxxxxx rKjmsxE@xxxxxxxxxxxxxxxxxx
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/