Commit 49204c11 authored by Antti P Miettinen's avatar Antti P Miettinen Committed by Linus Torvalds
Browse files

block/partitions/efi.c: fix bound check

Use ARRAY_SIZE instead of sizeof to get proper max for label length.

Since this is just a read out of bounds it's not that bad, but the
problem becomes user-visible eg if one tries to use DEBUG_PAGEALLOC and
DEBUG_RODATA, at least with some enhancements from Hiroshi.  Of course
the destination array can contain garbage when we read beyond the end of
source array so that would be another user-visible problem.
Signed-off-by: default avatarAntti P Miettinen <>
Reviewed-by: default avatarHiroshi Doyu <>
Tested-by: default avatarHiroshi Doyu <>
Cc: Will Drewry <>
Cc: Matt Fleming <>
Acked-by: default avatarDavidlohr Bueso <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 51a0d036
......@@ -96,6 +96,7 @@
* - Code works, detects all the partitions.
#include <linux/kernel.h>
#include <linux/crc32.h>
#include <linux/ctype.h>
#include <linux/math64.h>
......@@ -715,8 +716,8 @@ int efi_partition(struct parsed_partitions *state)
efi_guid_unparse(&ptes[i].unique_partition_guid, info->uuid);
/* Naively convert UTF16-LE to 7 bits. */
label_max = min(sizeof(info->volname) - 1,
label_max = min(ARRAY_SIZE(info->volname) - 1,
info->volname[label_max] = 0;
while (label_count < label_max) {
u8 c = ptes[i].partition_name[label_count] & 0xff;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment