From: yumkam@gmail.com (Yuriy M. Kaminskiy)
To: util-linux@vger.kernel.org
Subject: fsck -l: fix racing between unlock/unlink and open
Date: Fri, 08 Apr 2016 00:59:29 +0300 [thread overview]
Message-ID: <m3bn5lqdvi.fsf@gmail.com> (raw)
[-- 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
next reply other threads:[~2016-04-07 21:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-07 21:59 Yuriy M. Kaminskiy [this message]
2016-04-18 10:22 ` fsck -l: fix racing between unlock/unlink and open Karel Zak
2016-04-19 14:58 ` Yuriy M. Kaminskiy
2016-04-20 10:13 ` Nir Soffer
2016-04-22 9:09 ` Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3bn5lqdvi.fsf@gmail.com \
--to=yumkam@gmail.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.