Blame SOURCES/0067-kpartx-hold-device-open-until-partitions-have-been-c.patch
|
|
e71b65 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
e71b65 |
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
e71b65 |
Date: Wed, 19 Oct 2022 12:57:10 -0500
|
|
|
e71b65 |
Subject: [PATCH] kpartx: hold device open until partitions have been created
|
|
|
e71b65 |
|
|
|
e71b65 |
kpartx was closing the whole device after it read the partition
|
|
|
e71b65 |
information off it. This allowed a race, where the device could be
|
|
|
e71b65 |
removed and another one created with the same major:minor, after kpartx
|
|
|
e71b65 |
read the partition information but before it created the partition
|
|
|
e71b65 |
devices.
|
|
|
e71b65 |
|
|
|
e71b65 |
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
e71b65 |
Reviewed-by: Martin Wilck <mwilck@suse.com>
|
|
|
e71b65 |
---
|
|
|
e71b65 |
kpartx/kpartx.c | 11 +++--------
|
|
|
e71b65 |
1 file changed, 3 insertions(+), 8 deletions(-)
|
|
|
e71b65 |
|
|
|
e71b65 |
diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c
|
|
|
e71b65 |
index 7bc64543..e79fdd4a 100644
|
|
|
e71b65 |
--- a/kpartx/kpartx.c
|
|
|
e71b65 |
+++ b/kpartx/kpartx.c
|
|
|
e71b65 |
@@ -443,12 +443,7 @@ main(int argc, char **argv){
|
|
|
e71b65 |
if (n >= 0)
|
|
|
e71b65 |
printf("%s: %d slices\n", ptp->type, n);
|
|
|
e71b65 |
#endif
|
|
|
e71b65 |
-
|
|
|
e71b65 |
- if (n > 0) {
|
|
|
e71b65 |
- close(fd);
|
|
|
e71b65 |
- fd = -1;
|
|
|
e71b65 |
- }
|
|
|
e71b65 |
- else
|
|
|
e71b65 |
+ if (n <= 0)
|
|
|
e71b65 |
continue;
|
|
|
e71b65 |
|
|
|
e71b65 |
switch(what) {
|
|
|
e71b65 |
@@ -668,9 +663,9 @@ main(int argc, char **argv){
|
|
|
e71b65 |
if (n > 0)
|
|
|
e71b65 |
break;
|
|
|
e71b65 |
}
|
|
|
e71b65 |
+ if (fd != -1)
|
|
|
e71b65 |
+ close(fd);
|
|
|
e71b65 |
if (what == LIST && loopcreated) {
|
|
|
e71b65 |
- if (fd != -1)
|
|
|
e71b65 |
- close(fd);
|
|
|
e71b65 |
if (del_loop(device)) {
|
|
|
e71b65 |
if (verbose)
|
|
|
e71b65 |
fprintf(stderr, "can't del loop : %s\n",
|