Bug 443062 - pvcreate does not zero swap signatures
Summary: pvcreate does not zero swap signatures
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: lvm2
Version: rawhide
Hardware: All
OS: Linux
medium
low
Target Milestone: ---
Assignee: Petr Rockai
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-04-18 13:53 UTC by Eric Sandeen
Modified: 2009-05-19 12:27 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-05-19 12:27:23 UTC
Type: ---
Embargoed:


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

Description Eric Sandeen 2008-04-18 13:53:53 UTC
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 14:18:57 UTC
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 14:29:34 UTC
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 16:55:06 UTC
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 09:38:11 UTC
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 21:39:39 UTC
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 18:59:24 UTC
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 12:27:23 UTC
This has been checked in upstream.


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