Re: [PATCH] Race in pipe code

From: Manfred Spraul (manfred@colorfullife.com)
Date: Sun Jul 16 2000 - 01:26:15 EST


Christian Ehrhardt wrote:
>
> Hi,
>
> I can prove the race now (sample code attached) and I have a patch that fixes
> it for me. If noone sees problems with the patch I'll send it to Linus.
> The patch was developped for 2.3.99-pre9 but it applies cleanly against
> 2.4.0-test4.
>
> The nice(20) in the test program isn't needed, it just helps to trigger the
> race. About 50% of the time the program prints BBBBBBBBBB on stderr and
> 4000(!) A's on stdout which is clearly wrong. The patch basically makes
> sure that the same reader continues to read from the pipe after it went
> to sleep.
>
Why is that "clearly wrong"?
The POSIX.1 standard says

B.6.4.2 Write to a File
..
A write is atomic if the whole amount written in one operation is not
interleaved with data from any other process. This is useful when there
are multiple writers sending data to a single reader.

What you ask for is an atomicity guarantee for read, but AFAICS neither
B.6.4.1 nor 6.4.1 require such a guarantee.

--
	Manfred

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



This archive was generated by hypermail 2b29 : Sun Jul 23 2000 - 21:00:08 EST