All of lore.kernel.org
 help / color / mirror / Atom feed
* fsck -l: fix racing between unlock/unlink and open
@ 2016-04-07 21:59 Yuriy M. Kaminskiy
  2016-04-18 10:22 ` Karel Zak
  2016-04-22  9:09 ` Karel Zak
  0 siblings, 2 replies; 5+ messages in thread
From: Yuriy M. Kaminskiy @ 2016-04-07 21:59 UTC (permalink / raw)
  To: util-linux

[-- Attachment #1: Type: text/plain, Size: 57 bytes --]

Probably, there are better solutions, but I prefer KISS.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-fsck-fix-racing-between-unlock-and-unlink.patch --]
[-- Type: text/x-diff, Size: 1016 bytes --]

>From fcb97ddcbc336bc8860828c47cdaf21c7b1ca655 Mon Sep 17 00:00:00 2001
From: "Yuriy M. Kaminskiy" <yumkam@gmail.com>
Date: Fri, 8 Apr 2016 00:38:56 +0300
Subject: [PATCH] fsck: fix racing between unlock/unlink and open

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 | 1 -
 1 file changed, 1 deletion(-)

diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c
index 05cfbc4..84d2dcc 100644
--- a/disk-utils/fsck.c
+++ b/disk-utils/fsck.c
@@ -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);
 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-04-22  9:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-07 21:59 fsck -l: fix racing between unlock/unlink and open Yuriy M. Kaminskiy
2016-04-18 10:22 ` Karel Zak
2016-04-19 14:58   ` Yuriy M. Kaminskiy
2016-04-20 10:13   ` Nir Soffer
2016-04-22  9:09 ` Karel Zak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.