From: tip-bot for Vitaly Kuznetsov <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: torvalds@linux-foundation.org, peterz@infradead.org,
msalter@redhat.com, mingo@kernel.org, hpa@zytor.com,
vkuznets@redhat.com, ard.biesheuvel@linaro.org,
matt@codeblueprint.co.uk, linux-kernel@vger.kernel.org,
kys@microsoft.com, tglx@linutronix.de
Subject: [tip:efi/urgent] efi: Fix for_each_efi_memory_desc_in_map() for empty memmaps
Date: Fri, 3 Jun 2016 03:56:18 -0700 [thread overview]
Message-ID: <tip-55f1ea15216a5a14c96738bd5284100a00ffa9dc@git.kernel.org> (raw)
In-Reply-To: <1464690224-4503-2-git-send-email-matt@codeblueprint.co.uk>
Commit-ID: 55f1ea15216a5a14c96738bd5284100a00ffa9dc
Gitweb: http://git.kernel.org/tip/55f1ea15216a5a14c96738bd5284100a00ffa9dc
Author: Vitaly Kuznetsov <vkuznets@redhat.com>
AuthorDate: Tue, 31 May 2016 11:23:43 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 3 Jun 2016 09:57:35 +0200
efi: Fix for_each_efi_memory_desc_in_map() for empty memmaps
Commit:
78ce248faa3c ("efi: Iterate over efi.memmap in for_each_efi_memory_desc()")
introduced a regression for systems booted with the 'noefi' kernel option.
In particular, I observed an early kernel hang in efi_find_mirror()'s
for_each_efi_memory_desc() call. As we don't have efi memmap on this
system we enter this iterator with the following parameters:
efi.memmap.map = 0, efi.memmap.map_end = 0, efi.memmap.desc_size = 28
... then for_each_efi_memory_desc_in_map() does the following comparison:
(md) <= (efi_memory_desc_t *)((m)->map_end - (m)->desc_size);
... where md = 0, (m)->map_end = 0 and (m)->desc_size = 28 but when we subtract
something from a NULL pointer wrap around happens and we end up returning
invalid pointer and crash.
Fix it by using the correct pointer arithmetics.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mark Salter <msalter@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Fixes: 78ce248faa3c ("efi: Iterate over efi.memmap in for_each_efi_memory_desc()")
Link: http://lkml.kernel.org/r/1464690224-4503-2-git-send-email-matt@codeblueprint.co.uk
[ Made the changelog more readable. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
include/linux/efi.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/efi.h b/include/linux/efi.h
index c2db3ca..f196dd0 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -1005,7 +1005,7 @@ extern int efi_memattr_apply_permissions(struct mm_struct *mm,
/* Iterate through an efi_memory_map */
#define for_each_efi_memory_desc_in_map(m, md) \
for ((md) = (m)->map; \
- (md) <= (efi_memory_desc_t *)((m)->map_end - (m)->desc_size); \
+ ((void *)(md) + (m)->desc_size) <= (m)->map_end; \
(md) = (void *)(md) + (m)->desc_size)
/**
next prev parent reply other threads:[~2016-06-03 10:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-31 10:23 [GIT PULL 0/2] EFI urgent fixes Matt Fleming
2016-05-31 10:23 ` [PATCH 1/2] efi: Fix for_each_efi_memory_desc_in_map() for empty memmaps Matt Fleming
2016-06-03 10:56 ` tip-bot for Vitaly Kuznetsov [this message]
2016-05-31 10:23 ` [PATCH 2/2] efi/arm: Fix the format of debug message from efi Matt Fleming
2016-06-03 10:56 ` [tip:efi/urgent] efi/arm: Fix the format of EFI debug messages tip-bot for Dennis Chen
2016-06-06 10:02 ` [GIT PULL 0/2] EFI urgent fixes Matt Fleming
2016-06-08 7:24 ` Ingo Molnar
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-55f1ea15216a5a14c96738bd5284100a00ffa9dc@git.kernel.org \
--to=tipbot@zytor.com \
--cc=ard.biesheuvel@linaro.org \
--cc=hpa@zytor.com \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=matt@codeblueprint.co.uk \
--cc=mingo@kernel.org \
--cc=msalter@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=vkuznets@redhat.com \
/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).