]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
server: Fix assignment of afs_pid.
authorAndre Noll <maan@systemlinux.org>
Thu, 5 Nov 2009 23:21:16 +0000 (00:21 +0100)
committerAndre Noll <maan@systemlinux.org>
Thu, 5 Nov 2009 23:21:16 +0000 (00:21 +0100)
glibc-2.11 revealed the following bug in init_afs(): The assignment

mmd->afs_pid = fork();

results in undefined behaviour because fork() returns twice and mmd->afs_pid lives
in a shared memory area. Depending on whether the child runs first, this results in
mmd->afs_pid being either zero or the pid of the afs child process.

mmd->afs_pid being zero seems to happen always with glibc-2.11 and has rather
strange consequences:

First,  it causes para_server attempt to kill process 0 instead of the afs process on
exit. This fails because para_server never runs as root.  However, it may result in dirty
osl tables as the afs process might access mmd after the shared memory area containing
mmd has already been destroyed.

Second,  para_server fails to notice the death of the afs process, which is really bad and
may cause tons of error messages being written to the log.

Fix this bug by temporarily storing the afs pid in a local variable and setting mmd->afs_pid
only in the server (parent) process.


No differences found