aboutsummaryrefslogtreecommitdiffstats
path: root/fs/partitions/efi.c
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2009-11-23 03:29:58 -0500
committerJens Axboe <jens.axboe@oracle.com>2009-11-23 03:29:58 -0500
commit87038c2d5bda2418fda8b1456a0ae81cc3ff5bd8 (patch)
tree13a2250971f1309faae76ff2bbebda058ca99b32 /fs/partitions/efi.c
parent7d13af3279985f554784a45cc961f706dbcdbdd1 (diff)
partitions: read whole sector with EFI GPT header
The size of EFI GPT header is not static, but whole sector is allocated for the header. The HeaderSize field must be greater than 92 (= sizeof(struct gpt_header) and must be less than or equal to the logical block size. It means we have to read whole sector with the header, because the header crc32 checksum is calculated according to HeaderSize. For more details see UEFI standard (version 2.3, May 2009): - 5.3.1 GUID Format overview, page 93 - Table 13. GUID Partition Table Header, page 96 Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'fs/partitions/efi.c')
-rw-r--r--fs/partitions/efi.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/partitions/efi.c b/fs/partitions/efi.c
index 80eeff5fdfe0..49cfd5f54238 100644
--- a/fs/partitions/efi.c
+++ b/fs/partitions/efi.c
@@ -262,15 +262,16 @@ static gpt_header *
262alloc_read_gpt_header(struct block_device *bdev, u64 lba) 262alloc_read_gpt_header(struct block_device *bdev, u64 lba)
263{ 263{
264 gpt_header *gpt; 264 gpt_header *gpt;
265 unsigned ssz = bdev_logical_block_size(bdev);
266
265 if (!bdev) 267 if (!bdev)
266 return NULL; 268 return NULL;
267 269
268 gpt = kzalloc(sizeof (gpt_header), GFP_KERNEL); 270 gpt = kzalloc(ssz, GFP_KERNEL);
269 if (!gpt) 271 if (!gpt)
270 return NULL; 272 return NULL;
271 273
272 if (read_lba(bdev, lba, (u8 *) gpt, 274 if (read_lba(bdev, lba, (u8 *) gpt, ssz) < ssz) {
273 sizeof (gpt_header)) < sizeof (gpt_header)) {
274 kfree(gpt); 275 kfree(gpt);
275 gpt=NULL; 276 gpt=NULL;
276 return NULL; 277 return NULL;