From: tip-bot for Dan Carpenter <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, ard.biesheuvel@linaro.org,
mingo@kernel.org, torvalds@linux-foundation.org,
peterz@infradead.org, hpa@zytor.com, dan.carpenter@oracle.com,
ivan.hu@canonical.com, matt@codeblueprint.co.uk,
tglx@linutronix.de
Subject: [tip:efi/urgent] efi/efi_test: Prevent an Oops in efi_runtime_query_capsulecaps()
Date: Wed, 25 Oct 2017 04:09:52 -0700 [thread overview]
Message-ID: <tip-092e72c9edab16d4d6ad10c683a95047d53b6db4@git.kernel.org> (raw)
In-Reply-To: <20171025100448.26056-2-ard.biesheuvel@linaro.org>
Commit-ID: 092e72c9edab16d4d6ad10c683a95047d53b6db4
Gitweb: https://git.kernel.org/tip/092e72c9edab16d4d6ad10c683a95047d53b6db4
Author: Dan Carpenter <dan.carpenter@oracle.com>
AuthorDate: Wed, 25 Oct 2017 11:04:47 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 25 Oct 2017 12:10:59 +0200
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.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: Ivan Hu <ivan.hu@canonical.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Fixes: ff6301dabc3c ("efi: Add efi_test driver for exporting UEFI runtime service interfaces")
Link: http://lkml.kernel.org/r/20171025100448.26056-2-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
drivers/firmware/efi/test/efi_test.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers/firmware/efi/test/efi_test.c
index 08129b7..41c48a1 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)
next prev parent reply other threads:[~2017-10-25 11:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-25 10:04 [GIT PULL 0/2] EFI fixes for v4.14 Ard Biesheuvel
2017-10-25 10:04 ` [PATCH 1/2] efi/efi_test: Prevent an Oops in efi_runtime_query_capsulecaps() Ard Biesheuvel
2017-10-25 11:09 ` tip-bot for Dan Carpenter [this message]
2017-10-25 10:04 ` [PATCH 2/2] efi/libstub: arm: don't randomize runtime regions when CONFIG_HIBERNATION=y Ard Biesheuvel
2017-10-25 11:10 ` [tip:efi/urgent] efi/libstub/arm: Don't " tip-bot for Ard Biesheuvel
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=tip-092e72c9edab16d4d6ad10c683a95047d53b6db4@git.kernel.org \
--to=tipbot@zytor.com \
--cc=ard.biesheuvel@linaro.org \
--cc=dan.carpenter@oracle.com \
--cc=hpa@zytor.com \
--cc=ivan.hu@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=matt@codeblueprint.co.uk \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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
Powered by JetHome