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