This service will be undergoing maintenance at 00:00 UTC, 2016-08-01. It is expected to last about 1 hours
Bug 443062 - pvcreate does not zero swap signatures
pvcreate does not zero swap signatures
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: lvm2 (Show other bugs)
rawhide
All Linux
medium Severity low
: ---
: ---
Assigned To: Petr Rockai
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-04-18 09:53 EDT by Eric Sandeen
Modified: 2009-05-19 08:27 EDT (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-05-19 08:27:23 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
lvm-pvcreate-wipe-swap.diff (4.68 KB, patch)
2009-03-16 14:59 EDT, Petr Rockai
no flags Details | Diff

  None (edit)
Description Eric Sandeen 2008-04-18 09:53:53 EDT
this sequence on a machine with 4k page size:

xfs_io -F -c "pwrite 0 4096" /dev/sdb2
pvcreate -u 92e4895d-a9c2-4a70-8f02-b8f67372e506 /dev/sdb2
mkswap -U 92e4895d-a9c2-4a70-8f02-b8f67372e506 /dev/sdb2

generates exactly the same first 4k on the block device as this sequence:

xfs_io -F -c "pwrite 0 4096" /dev/sdb2
mkswap -U 92e4895d-a9c2-4a70-8f02-b8f67372e506 /dev/sdb2
pvcreate -u 92e4895d-a9c2-4a70-8f02-b8f67372e506 /dev/sdb2

making it awfully hard to know if the device is truly swap or not:

00000000  cd cd cd cd cd cd cd cd  cd cd cd cd cd cd cd cd  |................|
*
00000200  4c 41 42 45 4c 4f 4e 45  01 00 00 00 00 00 00 00  |LABELONE........|
00000210  19 e6 90 d1 20 00 00 00  4c 56 4d 32 20 30 30 31  |.... ...LVM2 001|
00000220  39 32 65 34 38 39 35 64  61 39 63 32 34 61 37 30  |92e4895da9c24a70|
00000230  38 66 30 32 62 38 66 36  37 33 37 32 65 35 30 36  |8f02b8f67372e506|
00000240  00 d0 2d e6 1b 00 00 00  00 00 03 00 00 00 00 00  |..-.............|
00000250  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000260  00 00 00 00 00 00 00 00  00 10 00 00 00 00 00 00  |................|
00000270  00 f0 02 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000280  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000400  01 00 00 00 dc 62 be 01  00 00 00 00 92 e4 89 5d  |.....b.........]|
00000410  a9 c2 4a 70 8f 02 b8 f6  73 72 e5 06 00 00 00 00  |..Jp....sr......|
00000420  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000ff0  00 00 00 00 00 00 53 57  41 50 53 50 41 43 45 32  |......SWAPSPACE2|
00001000

(the xfs_io command simply patterns the first 4k to make it obvious what has
been re-written)

It seems like it would be wise for pvcreate to zero out at least the first
page-sized chunk of the device, to eliminate old swap signatures or anything
else that might be out there.

Thanks,
-Eric
Comment 1 Alasdair Kergon 2008-04-18 10:18:57 EDT
LVM2 wipes the first 2k (see man page) as that's where LVM2 can write its label
(depending on options).  There is an option already to disable wiping that.  I
think it's probably safe to increase the amount it wipes - though it might be
better to add a check for a swap signature and require confirmation first.
Comment 2 Eric Sandeen 2008-04-18 10:29:34 EDT
Ah, sorry, missed the part in the manpage about not doing the wiping if --uuid
is specified.

I'm on the fence about asking for confirmation if swap is found; should you
check for every old signature of everything you might find?  It gets cumbersome...
Comment 3 Petr Rockai 2008-05-05 12:55:06 EDT
This is also partially related to 
https://bugzilla.redhat.com/show_bug.cgi?id=174700 (about the warning). 
Increasing wipe size is certainly an option as well (I don't think this will 
have any adverse effects, so I'm all for doing that in CVS).
Comment 4 Bug Zapper 2008-05-14 05:38:11 EDT
Changing version to '9' as part of upcoming Fedora 9 GA.
More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 5 Alasdair Kergon 2009-03-03 16:39:39 EST
Unless it's particularly awkward to do, I'd prefer to recognise the signature in pvcreate.c and ask people whether or not to wipe it, like we do with md superblocks, so they are aware of what they are doing.
Comment 6 Petr Rockai 2009-03-16 14:59:24 EDT
Created attachment 335395 [details]
lvm-pvcreate-wipe-swap.diff

Proposed patch to address this issue. Upstream review pending.
Comment 7 Petr Rockai 2009-05-19 08:27:23 EDT
This has been checked in upstream.

Note You need to log in before you can comment on or make changes to this bug.