]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fsck: fix racing between unlock/unlink and open
authorYuriy M. Kaminskiy <yumkam@gmail.com>
Thu, 7 Apr 2016 21:38:56 +0000 (00:38 +0300)
committerKarel Zak <kzak@redhat.com>
Fri, 22 Apr 2016 09:07:42 +0000 (11:07 +0200)
Process A Process B Process C
open()
[creates file]
lock()
[succeed]
open()
[open existing]
lock()...
running()
close()
[...succeed]
unlink()
running()
open()
[creates file] {BAD!}
lock()
[succeed] {BAD!}
running() {BAD!}
close()

Cons: leaves empty (unlocked/harmless) .lock files in /run/fsck/
Signed-off-by: Yuriy M. Kaminskiy <yumkam@gmail.com>
disk-utils/fsck.c

index 05cfbc43905d0c51f0ff3922c125948aaafd022e..84d2dcc3d4056036325828579171b6059959cada 100644 (file)
@@ -410,7 +410,6 @@ static void unlock_disk(struct fsck_instance *inst)
                printf(_("Unlocking %s.\n"), inst->lockpath);
 
        close(inst->lock);                      /* unlock */
-       unlink(inst->lockpath);
 
        free(inst->lockpath);