linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Fleming <matt@codeblueprint.co.uk>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Ivan Hu <ivan.hu@canonical.com>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	linux-efi@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] efi/efi_test: Prevent an Oops in efi_runtime_query_capsulecaps()
Date: Fri, 6 Oct 2017 13:19:39 +0100	[thread overview]
Message-ID: <20171006121939.GC3314@codeblueprint.co.uk> (raw)
In-Reply-To: <20170930081732.x6g4b2mwxwt5xzql@mwanda>

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?

  reply	other threads:[~2017-10-06 12:19 UTC|newest]

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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171006121939.GC3314@codeblueprint.co.uk \
    --to=matt@codeblueprint.co.uk \
    --cc=ard.biesheuvel@linaro.org \
    --cc=dan.carpenter@oracle.com \
    --cc=ivan.hu@canonical.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-efi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).