1
0
forked from pool/util-linux

Accepting request 396830 from home:sbrabec:branches:util-linux-bsc976141

According to  Arvin Schnell, we need these fixes in openSUSE Factory now.
Otherwise they cannot commit code using parted --wipesignatures.

- blkid: Wipe corect area for probes with offset (bsc#976141,
  util-linux-libblkid-wipe-offset.patch).

OBS-URL: https://build.opensuse.org/request/show/396830
OBS-URL: https://build.opensuse.org/package/show/Base:System/util-linux?expand=0&rev=307
This commit is contained in:
Marcus Meissner 2016-05-23 15:22:26 +00:00 committed by Git OBS Bridge
parent 15f40b602e
commit 02b4738ea8
7 changed files with 127 additions and 0 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu May 19 14:29:27 CEST 2016 - sbrabec@suse.com
- blkid: Wipe corect area for probes with offset (bsc#976141,
util-linux-libblkid-wipe-offset.patch).
-------------------------------------------------------------------
Tue Apr 26 18:24:40 CEST 2016 - sbrabec@suse.com

View File

@ -155,6 +155,8 @@ Source51: blkid.conf
##
## util-linux patches
##
# PATCH-FIX-UPSTREAM util-linux-libblkid-wipe-offset.patch bsc976141 sbrabec@suse.com -- blkid: Wipe corect area for probes with offset
Patch: util-linux-libblkid-wipe-offset.patch
# PATCH-EXTEND-UPSTREAM: Let `su' handle /sbin and /usr/sbin in path
Patch4: make-sure-sbin-resp-usr-sbin-are-in-PATH.diff
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@ -392,6 +394,7 @@ library.
xzcat %{S:0} | %gpg_verify -p %{_name} %{S:12} -
%endif
%setup -q -n %{_name}-%{version} -b 40
%patch -p1
%patch4 -p1
#
# setctsid

View File

@ -0,0 +1,100 @@
From 445e6b1ec82642a298419bdd18a81110593bfbaa Mon Sep 17 00:00:00 2001
From: Petr Uzel <petr.uzel@suse.cz>
Date: Mon, 18 Apr 2016 16:22:05 +0200
Subject: [PATCH] libblkid: make blkid_do_wipe() work with probes with offset
When a probe is created with an offset, e.g. via
blkid_probe_set_device(), this offset is correctly used when looking for
the signatures, but is not respected by blkid_do_wipe() function.
Therefore the signature is removed from an invalid location.
Usecase: Wiping signatures from an area on the block device where
partition is to be created (but as it does not exist yet, there's no
device node for it and probe on the whole block device has to be used
with correct offset and length).
Reproducer:
======================== wiper.c ===========================
const char *dev;
unsigned long offset;
unsigned long size;
int main(int argc, char** argv) {
if (argc != 4) {
printf("usage: wiper dev offset size\n");
exit(1);
}
dev = argv[1];
offset = strtoull(argv[2], NULL, 10);
size = strtoull(argv[3], NULL, 10);
printf("dev=%s, off=%llu, size=%llu\n", dev, offset, size);
int fd = open (dev, O_RDWR);
if (fd == -1) {
perror("open");
exit(1);
}
blkid_loff_t wipe_offset = offset * SECTOR_SIZE;
blkid_loff_t wipe_size = size * SECTOR_SIZE;
int ret;
blkid_probe pr;
pr = blkid_new_probe();
if (!pr)
return 0;
ret = blkid_probe_set_device(pr, fd, wipe_offset, wipe_size);
ret = blkid_probe_enable_superblocks(pr, 1);
ret = blkid_probe_set_superblocks_flags(pr, BLKID_SUBLKS_MAGIC);
while (blkid_do_probe(pr) == 0) {
ret = blkid_do_wipe(pr, 0);
}
blkid_free_probe(pr);
close(fd);
}
======================== wiper.c ===========================
Steps to reproduce:
modprobe scsi_debug
parted -s /dev/sdX mklabel gpt
parted -s /dev/sdX mkpart first 2048s 4095s
mkfs.ext2 /dev/sdX1
wipefs -np /dev/sdX1
./wiper /dev/sdX1 2048 2048
Actual result: wiper gets into endless loop, because
blkid_do_wipe() wipes at wrong location (1080), leaving the signature
on /dev/sdc1. So it is again found by blkid_do_probe(), and so on.
Expected result: wiper clears the ext2 signature at offset 1049656(=1080+2048*512).
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
libblkid/src/probe.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c
index 34d97b8..0c8625c 100644
--- a/libblkid/src/probe.c
+++ b/libblkid/src/probe.c
@@ -1121,7 +1121,7 @@ int blkid_do_wipe(blkid_probe pr, int dryrun)
if (rc || len == 0 || off == NULL)
return 0;
- offset = strtoumax(off, NULL, 10);
+ offset = strtoumax(off, NULL, 10) + pr->off;
fd = blkid_probe_get_fd(pr);
if (fd < 0)
return -1;
--
2.8.1

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu May 19 14:29:27 CEST 2016 - sbrabec@suse.com
- blkid: Wipe corect area for probes with offset (bsc#976141,
util-linux-libblkid-wipe-offset.patch).
-------------------------------------------------------------------
Tue Apr 26 18:24:40 CEST 2016 - sbrabec@suse.com

View File

@ -155,6 +155,8 @@ Source51: blkid.conf
##
## util-linux patches
##
# PATCH-FIX-UPSTREAM util-linux-libblkid-wipe-offset.patch bsc976141 sbrabec@suse.com -- blkid: Wipe corect area for probes with offset
Patch: util-linux-libblkid-wipe-offset.patch
# PATCH-EXTEND-UPSTREAM: Let `su' handle /sbin and /usr/sbin in path
Patch4: make-sure-sbin-resp-usr-sbin-are-in-PATH.diff
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@ -392,6 +394,7 @@ library.
xzcat %{S:0} | %gpg_verify -p %{_name} %{S:12} -
%endif
%setup -q -n %{_name}-%{version} -b 40
%patch -p1
%patch4 -p1
#
# setctsid

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu May 19 14:29:27 CEST 2016 - sbrabec@suse.com
- blkid: Wipe corect area for probes with offset (bsc#976141,
util-linux-libblkid-wipe-offset.patch).
-------------------------------------------------------------------
Tue Apr 26 18:24:40 CEST 2016 - sbrabec@suse.com

View File

@ -155,6 +155,8 @@ Source51: blkid.conf
##
## util-linux patches
##
# PATCH-FIX-UPSTREAM util-linux-libblkid-wipe-offset.patch bsc976141 sbrabec@suse.com -- blkid: Wipe corect area for probes with offset
Patch: util-linux-libblkid-wipe-offset.patch
# PATCH-EXTEND-UPSTREAM: Let `su' handle /sbin and /usr/sbin in path
Patch4: make-sure-sbin-resp-usr-sbin-are-in-PATH.diff
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@ -392,6 +394,7 @@ library.
xzcat %{S:0} | %gpg_verify -p %{_name} %{S:12} -
%endif
%setup -q -n %{_name}-%{version} -b 40
%patch -p1
%patch4 -p1
#
# setctsid