efi/efi_test: Prevent an Oops in efi_runtime_query_capsulecaps()
Subsystems (3)
PATCH 1/1 efi/efi_test: Prevent an Oops in efi_runtime_query_capsulecaps()
If "qcaps.capsule_count" is ULONG_MAX then "qcaps.capsule_count + 1" will overflow to zero and kcalloc() will return the ZERO_SIZE_PTR. We try to dereference it inside the loop and crash.
drivers/firmware/efi/test/efi_test.c +3 -0
@@ -593,6 +593,9 @@ static long efi_runtime_query_capsulecaps(unsigned long arg)if (copy_from_user (&qcaps, qcaps_user,sizeof (qcaps)))return -EFAULT ; +if (qcaps.capsule_count =ULONG_MAX ) +return -EINVAL ; + capsules =kcalloc (qcaps.capsule_count +1 ,sizeof (efi_capsule_header_t),GFP_KERNEL );if (!capsules)
Quoted 12 lines · Dan Carpenter
If "qcaps.capsule_count" is
ULONG_MAXthen "qcaps.capsule_count + 1" will overflow to zero andkcalloc()will return theZERO_SIZE_PTR. We try to dereference it inside the loop and crash.Fixes ff6301dabc3c ("efi: Add efi_test driver for exporting UEFI runtime service interfaces")Signed-off-by Dan Carpenter <[email protected]>drivers/firmware/efi/test/efi_test.c +0
-0
drivers/firmware/efi/test/efi_test.c static long efi_runtime_query_capsulecaps(unsigned long arg) · line 601
Quoted 9 lines
drivers/firmware/efi/test/efi_test.c +3
-0@@ -593,6 +593,9 @@ static long efi_runtime_query_capsulecaps(unsigned long arg)if (copy_from_user (&qcaps, qcaps_user,sizeof (qcaps)))return -EFAULT ; +if (qcaps.capsule_count =ULONG_MAX ) +return -EINVAL ; + capsules =kcalloc (qcaps.capsule_count +1 ,sizeof (efi_capsule_header_t),GFP_KERNEL );if (!capsules)
This looks OK to me. Ivan?
A message that is not in the archive (sent off-list or not yet received): 20171006121939.GC3314-mF/unelCI9GS6iBeEJttW/[email protected]
ACK: [PATCH] efi/efi_test: Prevent an Oops in efi_runtime_query_capsulecaps()
Quoted 16 lines · Matt Fleming
Quoted 15 lines · Dan Carpenter
If "qcaps.capsule_count" is
ULONG_MAXthen "qcaps.capsule_count + 1" will overflow to zero andkcalloc()will return theZERO_SIZE_PTR. We try to dereference it inside the loop and crash.Fixes ff6301dabc3c ("efi: Add efi_test driver for exporting UEFI runtime service interfaces")Signed-off-by Dan Carpenter <[email protected]>drivers/firmware/efi/test/efi_test.c +0
-0@@ -593,6 +593,9 @@ static long efi_runtime_query_capsulecaps(unsigned long arg)if (copy_from_user (&qcaps, qcaps_user,sizeof (qcaps)))return -EFAULT ;
Quoted 9 lines
drivers/firmware/efi/test/efi_test.c static long efi_runtime_query_capsulecaps(unsigned long arg) · line 601
Quoted 6 lines
drivers/firmware/efi/test/efi_test.c +3
-0+if (qcaps.capsule_count =ULONG_MAX ) +return -EINVAL ; + capsules =kcalloc (qcaps.capsule_count +1 ,sizeof (efi_capsule_header_t),GFP_KERNEL );if (!capsules)This looks OK to me. Ivan?
Matt Fleming
AppliedRe: ACK: [PATCH] efi/efi_test: Prevent an Oops in efi_runtime_query_capsulecaps()
Quoted 29 lines · Ivan Hu
Quoted 8 lines · Matt Fleming
Quoted 7 lines · Dan Carpenter
If "qcaps.capsule_count" is
ULONG_MAXthen "qcaps.capsule_count + 1" will overflow to zero andkcalloc()will return theZERO_SIZE_PTR. We try to dereference it inside the loop and crash.Fixes ff6301dabc3c ("efi: Add efi_test driver for exporting UEFI runtime service interfaces")Signed-off-by Dan Carpenter <[email protected]>Quoted 16 lines
drivers/firmware/efi/test/efi_test.c static long efi_runtime_query_capsulecaps(unsigned long arg) · line 600
Quoted 13 lines
drivers/firmware/efi/test/efi_test.c +3
-0@@ -593,6 +593,9 @@ static long efi_runtime_query_capsulecaps(unsigned long arg)if (copy_from_user (&qcaps, qcaps_user,sizeof (qcaps)))return -EFAULT ; +if (qcaps.capsule_count =ULONG_MAX ) +return -EINVAL ; + capsules =kcalloc (qcaps.capsule_count +1 ,sizeof (efi_capsule_header_t),GFP_KERNEL );if (!capsules)This looks OK to me. Ivan?
Quoted 1 line
Acked-by Ivan Hu <[email protected]>
Thanks, applied.