All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] efi/efi_test: Prevent an Oops in efi_runtime_query_capsulecaps()
@ 2017-09-30  8:17 ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2017-09-30  8:17 UTC (permalink / raw)
  To: Ivan Hu
  Cc: Matt Fleming, Ard Biesheuvel, linux-efi-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

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.

Fixes: ff6301dabc3c ("efi: Add efi_test driver for exporting UEFI runtime service interfaces")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers/firmware/efi/test/efi_test.c
index 08129b7b80ab..41c48a1e8baa 100644
--- a/drivers/firmware/efi/test/efi_test.c
+++ b/drivers/firmware/efi/test/efi_test.c
@@ -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)

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] efi/efi_test: Prevent an Oops in efi_runtime_query_capsulecaps()
@ 2017-09-30  8:17 ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2017-09-30  8:17 UTC (permalink / raw)
  To: Ivan Hu
  Cc: Matt Fleming, Ard Biesheuvel, linux-efi-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

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.

Fixes: ff6301dabc3c ("efi: Add efi_test driver for exporting UEFI runtime service interfaces")
Signed-off-by: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers/firmware/efi/test/efi_test.c
index 08129b7b80ab..41c48a1e8baa 100644
--- a/drivers/firmware/efi/test/efi_test.c
+++ b/drivers/firmware/efi/test/efi_test.c
@@ -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)

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] efi/efi_test: Prevent an Oops in efi_runtime_query_capsulecaps()
  2017-09-30  8:17 ` Dan Carpenter
@ 2017-10-06 12:19   ` Matt Fleming
  -1 siblings, 0 replies; 8+ messages in thread
From: Matt Fleming @ 2017-10-06 12:19 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Ivan Hu, Ard Biesheuvel, linux-efi, kernel-janitors

On Sat, 30 Sep, at 11:17:32AM, Dan Carpenter wrote:
> 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.
> 
> Fixes: ff6301dabc3c ("efi: Add efi_test driver for exporting UEFI runtime service interfaces")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers/firmware/efi/test/efi_test.c
> index 08129b7b80ab..41c48a1e8baa 100644
> --- a/drivers/firmware/efi/test/efi_test.c
> +++ b/drivers/firmware/efi/test/efi_test.c
> @@ -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?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] efi/efi_test: Prevent an Oops in efi_runtime_query_capsulecaps()
@ 2017-10-06 12:19   ` Matt Fleming
  0 siblings, 0 replies; 8+ messages in thread
From: Matt Fleming @ 2017-10-06 12:19 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Ivan Hu, Ard Biesheuvel, linux-efi, kernel-janitors

On Sat, 30 Sep, at 11:17:32AM, Dan Carpenter wrote:
> 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.
> 
> Fixes: ff6301dabc3c ("efi: Add efi_test driver for exporting UEFI runtime service interfaces")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers/firmware/efi/test/efi_test.c
> index 08129b7b80ab..41c48a1e8baa 100644
> --- a/drivers/firmware/efi/test/efi_test.c
> +++ b/drivers/firmware/efi/test/efi_test.c
> @@ -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?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* ACK: [PATCH] efi/efi_test: Prevent an Oops in efi_runtime_query_capsulecaps()
       [not found]   ` <20171006121939.GC3314-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
@ 2017-10-11  6:26       ` ivanhu
  0 siblings, 0 replies; 8+ messages in thread
From: ivanhu @ 2017-10-11  6:26 UTC (permalink / raw)
  To: Matt Fleming, Dan Carpenter
  Cc: Ard Biesheuvel, linux-efi-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA



On 10/06/2017 08:19 PM, Matt Fleming wrote:
> On Sat, 30 Sep, at 11:17:32AM, Dan Carpenter wrote:
>> 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.
>>
>> Fixes: ff6301dabc3c ("efi: Add efi_test driver for exporting UEFI runtime service interfaces")
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>>
>> diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers/firmware/efi/test/efi_test.c
>> index 08129b7b80ab..41c48a1e8baa 100644
>> --- a/drivers/firmware/efi/test/efi_test.c
>> +++ b/drivers/firmware/efi/test/efi_test.c
>> @@ -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?
> 


Acked-by: Ivan Hu <ivan.hu@canonical.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* ACK: [PATCH] efi/efi_test: Prevent an Oops in efi_runtime_query_capsulecaps()
@ 2017-10-11  6:26       ` ivanhu
  0 siblings, 0 replies; 8+ messages in thread
From: ivanhu @ 2017-10-11  6:26 UTC (permalink / raw)
  To: Matt Fleming, Dan Carpenter
  Cc: Ard Biesheuvel, linux-efi-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA



On 10/06/2017 08:19 PM, Matt Fleming wrote:
> On Sat, 30 Sep, at 11:17:32AM, Dan Carpenter wrote:
>> 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.
>>
>> Fixes: ff6301dabc3c ("efi: Add efi_test driver for exporting UEFI runtime service interfaces")
>> Signed-off-by: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
>>
>> diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers/firmware/efi/test/efi_test.c
>> index 08129b7b80ab..41c48a1e8baa 100644
>> --- a/drivers/firmware/efi/test/efi_test.c
>> +++ b/drivers/firmware/efi/test/efi_test.c
>> @@ -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?
> 


Acked-by: Ivan Hu <ivan.hu-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ACK: [PATCH] efi/efi_test: Prevent an Oops in efi_runtime_query_capsulecaps()
  2017-10-11  6:26       ` ivanhu
@ 2017-10-11  9:34         ` Matt Fleming
  -1 siblings, 0 replies; 8+ messages in thread
From: Matt Fleming @ 2017-10-11  9:34 UTC (permalink / raw)
  To: ivanhu; +Cc: Dan Carpenter, Ard Biesheuvel, linux-efi, kernel-janitors

On Wed, 11 Oct, at 02:26:57PM, Ivan Hu wrote:
> 
> 
> On 10/06/2017 08:19 PM, Matt Fleming wrote:
> >On Sat, 30 Sep, at 11:17:32AM, Dan Carpenter wrote:
> >>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.
> >>
> >>Fixes: ff6301dabc3c ("efi: Add efi_test driver for exporting UEFI runtime service interfaces")
> >>Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >>
> >>diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers/firmware/efi/test/efi_test.c
> >>index 08129b7b80ab..41c48a1e8baa 100644
> >>--- a/drivers/firmware/efi/test/efi_test.c
> >>+++ b/drivers/firmware/efi/test/efi_test.c
> >>@@ -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?
> >
> 
> 
> Acked-by: Ivan Hu <ivan.hu@canonical.com>

Thanks, applied.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: ACK: [PATCH] efi/efi_test: Prevent an Oops in efi_runtime_query_capsulecaps()
@ 2017-10-11  9:34         ` Matt Fleming
  0 siblings, 0 replies; 8+ messages in thread
From: Matt Fleming @ 2017-10-11  9:34 UTC (permalink / raw)
  To: ivanhu; +Cc: Dan Carpenter, Ard Biesheuvel, linux-efi, kernel-janitors

On Wed, 11 Oct, at 02:26:57PM, Ivan Hu wrote:
> 
> 
> On 10/06/2017 08:19 PM, Matt Fleming wrote:
> >On Sat, 30 Sep, at 11:17:32AM, Dan Carpenter wrote:
> >>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.
> >>
> >>Fixes: ff6301dabc3c ("efi: Add efi_test driver for exporting UEFI runtime service interfaces")
> >>Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >>
> >>diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers/firmware/efi/test/efi_test.c
> >>index 08129b7b80ab..41c48a1e8baa 100644
> >>--- a/drivers/firmware/efi/test/efi_test.c
> >>+++ b/drivers/firmware/efi/test/efi_test.c
> >>@@ -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?
> >
> 
> 
> Acked-by: Ivan Hu <ivan.hu@canonical.com>

Thanks, applied.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-10-11  9:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-30  8:17 [PATCH] efi/efi_test: Prevent an Oops in efi_runtime_query_capsulecaps() Dan Carpenter
2017-09-30  8:17 ` Dan Carpenter
2017-10-06 12:19 ` Matt Fleming
2017-10-06 12:19   ` Matt Fleming
     [not found]   ` <20171006121939.GC3314-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2017-10-11  6:26     ` ACK: " ivanhu
2017-10-11  6:26       ` ivanhu
2017-10-11  9:34       ` Matt Fleming
2017-10-11  9:34         ` Matt Fleming

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.