/[linux-patches]/genpatches-2.6/trunk/2.6.32/1900_EFI-GPT-header-read-fix.patch
Gentoo

Contents of /genpatches-2.6/trunk/2.6.32/1900_EFI-GPT-header-read-fix.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1646 - (show annotations) (download) (as text)
Sat Dec 19 19:11:24 2009 UTC (10 years, 11 months ago) by mpagano
File MIME type: text/x-diff
File size: 2456 byte(s)
Patches to correct sector size reads for EFI GPT
1 From: Karel Zak <kzak@redhat.com>
2 Date: Mon, 23 Nov 2009 08:29:58 +0000 (+0100)
3 Subject: partitions: read whole sector with EFI GPT header
4 X-Git-Tag: v2.6.33-rc1~379^2~53
5 X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=87038c2d5bda2418fda8b1456a0ae81cc3ff5bd8
6
7 partitions: read whole sector with EFI GPT header
8
9 The size of EFI GPT header is not static, but whole sector is
10 allocated for the header. The HeaderSize field must be greater
11 than 92 (= sizeof(struct gpt_header) and must be less than or
12 equal to the logical block size.
13
14 It means we have to read whole sector with the header, because the
15 header crc32 checksum is calculated according to HeaderSize.
16
17 For more details see UEFI standard (version 2.3, May 2009):
18 - 5.3.1 GUID Format overview, page 93
19 - Table 13. GUID Partition Table Header, page 96
20
21 Signed-off-by: Karel Zak <kzak@redhat.com>
22 Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
23 ---
24
25 diff --git a/fs/partitions/efi.c b/fs/partitions/efi.c
26 index 80eeff5..49cfd5f 100644
27 --- a/fs/partitions/efi.c
28 +++ b/fs/partitions/efi.c
29 @@ -262,15 +262,16 @@ static gpt_header *
30 alloc_read_gpt_header(struct block_device *bdev, u64 lba)
31 {
32 gpt_header *gpt;
33 + unsigned ssz = bdev_logical_block_size(bdev);
34 +
35 if (!bdev)
36 return NULL;
37
38 - gpt = kzalloc(sizeof (gpt_header), GFP_KERNEL);
39 + gpt = kzalloc(ssz, GFP_KERNEL);
40 if (!gpt)
41 return NULL;
42
43 - if (read_lba(bdev, lba, (u8 *) gpt,
44 - sizeof (gpt_header)) < sizeof (gpt_header)) {
45 + if (read_lba(bdev, lba, (u8 *) gpt, ssz) < ssz) {
46 kfree(gpt);
47 gpt=NULL;
48 return NULL;
49 diff --git a/fs/partitions/efi.h b/fs/partitions/efi.h
50 index 2cc89d0..6998b58 100644
51 --- a/fs/partitions/efi.h
52 +++ b/fs/partitions/efi.h
53 @@ -37,7 +37,6 @@
54 #define EFI_PMBR_OSTYPE_EFI 0xEF
55 #define EFI_PMBR_OSTYPE_EFI_GPT 0xEE
56
57 -#define GPT_BLOCK_SIZE 512
58 #define GPT_HEADER_SIGNATURE 0x5452415020494645ULL
59 #define GPT_HEADER_REVISION_V1 0x00010000
60 #define GPT_PRIMARY_PARTITION_TABLE_LBA 1
61 @@ -79,7 +78,12 @@ typedef struct _gpt_header {
62 __le32 num_partition_entries;
63 __le32 sizeof_partition_entry;
64 __le32 partition_entry_array_crc32;
65 - u8 reserved2[GPT_BLOCK_SIZE - 92];
66 +
67 + /* The rest of the logical block is reserved by UEFI and must be zero.
68 + * EFI standard handles this by:
69 + *
70 + * uint8_t reserved2[ BlockSize - 92 ];
71 + */
72 } __attribute__ ((packed)) gpt_header;
73
74 typedef struct _gpt_entry_attributes {
75

  ViewVC Help
Powered by ViewVC 1.1.20