read_elf(): eliminate race condition when checking /sbin/init
From Vasily (http://openvz.org/pipermail/devel/2012-July/028877.html):
stat()+open() is not atomic in the code below, so there is a race
condition. A container root may change /sbin/init between these calls
to e.g. FIFO and then make the vzctl's process hang up on read().
I'd add O_NOCTTY to open's flags and change stat() before open() to
fstat() just after open().
Fix according to the above comments.
Reported-by: Vasily Kulikov <segoon@openwall.com>
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
1 file changed