BUG: 2.4.x NFS client mmap race

Marcus Meissner (Marcus.Meissner@caldera.de)
Sat, 2 Jun 2001 23:17:37 +0200


Hi,

While debugging a rather strange WINE problem I came across a 2.4.x
NFS race condition.

I trimmed down the WINE code to a very small testcase, attached below,
which has following test patterns:

ext2 local : SUCCESS
2.4.5-ac6 -> 2.2.10 (unfsd) : FAIL
2.4.2-ac26 -> 2.4.2ac26 (knfsd) : FAIL
2.2.14 -> 2.4.2ac26 (knfsd) : SUCCESS

For me this looks like there is a problem in the 2.4 NFS client.

The sleep() appears to be a key part. If we only sleep 1 second the
test usually succeeds. With 5 it always fails.

I am using the default mount options for nfs.

Ciao, Marcus

#include <stdio.h>
#include <assert.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>

main() {
int fd;
unsigned char *ptr;
char buf[10];

memset(buf,'0',10);

fd = open("/home/lstcore/mm/test.out",O_RDWR|O_CREAT|O_TRUNC,0644);
assert(fd!=-1);

ftruncate(fd,512);
ptr=mmap(NULL,512,PROT_WRITE|PROT_READ,MAP_SHARED,fd,0);
ptr[0]=0x42;
munmap(ptr,512);

sleep(5);

ftruncate(fd,69632);
ptr=mmap(NULL,69632,PROT_WRITE|PROT_READ,MAP_SHARED,fd,0);
assert(ptr[0]==0x42);

fprintf(stderr,"There was no race. Lucky you!\n");
}
-
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/