stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Linn Crosetto <linn@hp.com>,
	Yinghai Lu <yinghai@kernel.org>,
	Pekka Enberg <penberg@kernel.org>,
	"H. Peter Anvin" <hpa@linux.intel.com>,
	Paul Gortmaker <paul.gortmaker@windriver.com>
Subject: [ 69/69] x86: avoid remapping data in parse_setup_data()
Date: Wed, 16 Oct 2013 10:45:18 -0700	[thread overview]
Message-ID: <20131016174321.349642916@linuxfoundation.org> (raw)
In-Reply-To: <20131016174312.844154919@linuxfoundation.org>

3.10-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Linn Crosetto <linn@hp.com>

commit 30e46b574a1db7d14404e52dca8e1aa5f5155fd2 upstream.

Type SETUP_PCI, added by setup_efi_pci(), may advertise a ROM size
larger than early_memremap() is able to handle, which is currently
limited to 256kB. If this occurs it leads to a NULL dereference in
parse_setup_data().

To avoid this, remap the setup_data header and allow parsing functions
for individual types to handle their own data remapping.

Signed-off-by: Linn Crosetto <linn@hp.com>
Link: http://lkml.kernel.org/r/1376430401-67445-1-git-send-email-linn@hp.com
Acked-by: Yinghai Lu <yinghai@kernel.org>
Reviewed-by: Pekka Enberg <penberg@kernel.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/include/asm/e820.h |    2 +-
 arch/x86/kernel/e820.c      |    5 ++++-
 arch/x86/kernel/setup.c     |   19 ++++++++-----------
 3 files changed, 13 insertions(+), 13 deletions(-)

--- a/arch/x86/include/asm/e820.h
+++ b/arch/x86/include/asm/e820.h
@@ -29,7 +29,7 @@ extern void e820_setup_gap(void);
 extern int e820_search_gap(unsigned long *gapstart, unsigned long *gapsize,
 			unsigned long start_addr, unsigned long long end_addr);
 struct setup_data;
-extern void parse_e820_ext(struct setup_data *data);
+extern void parse_e820_ext(u64 phys_addr, u32 data_len);
 
 #if defined(CONFIG_X86_64) || \
 	(defined(CONFIG_X86_32) && defined(CONFIG_HIBERNATION))
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -658,15 +658,18 @@ __init void e820_setup_gap(void)
  * boot_params.e820_map, others are passed via SETUP_E820_EXT node of
  * linked list of struct setup_data, which is parsed here.
  */
-void __init parse_e820_ext(struct setup_data *sdata)
+void __init parse_e820_ext(u64 phys_addr, u32 data_len)
 {
 	int entries;
 	struct e820entry *extmap;
+	struct setup_data *sdata;
 
+	sdata = early_memremap(phys_addr, data_len);
 	entries = sdata->len / sizeof(struct e820entry);
 	extmap = (struct e820entry *)(sdata->data);
 	__append_e820_map(extmap, entries);
 	sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
+	early_iounmap(sdata, data_len);
 	printk(KERN_INFO "e820: extended physical RAM map:\n");
 	e820_print_map("extended");
 }
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -426,25 +426,23 @@ static void __init reserve_initrd(void)
 static void __init parse_setup_data(void)
 {
 	struct setup_data *data;
-	u64 pa_data;
+	u64 pa_data, pa_next;
 
 	pa_data = boot_params.hdr.setup_data;
 	while (pa_data) {
-		u32 data_len, map_len;
+		u32 data_len, map_len, data_type;
 
 		map_len = max(PAGE_SIZE - (pa_data & ~PAGE_MASK),
 			      (u64)sizeof(struct setup_data));
 		data = early_memremap(pa_data, map_len);
 		data_len = data->len + sizeof(struct setup_data);
-		if (data_len > map_len) {
-			early_iounmap(data, map_len);
-			data = early_memremap(pa_data, data_len);
-			map_len = data_len;
-		}
+		data_type = data->type;
+		pa_next = data->next;
+		early_iounmap(data, map_len);
 
-		switch (data->type) {
+		switch (data_type) {
 		case SETUP_E820_EXT:
-			parse_e820_ext(data);
+			parse_e820_ext(pa_data, data_len);
 			break;
 		case SETUP_DTB:
 			add_dtb(pa_data);
@@ -452,8 +450,7 @@ static void __init parse_setup_data(void
 		default:
 			break;
 		}
-		pa_data = data->next;
-		early_iounmap(data, map_len);
+		pa_data = pa_next;
 	}
 }
 



  parent reply	other threads:[~2013-10-16 17:45 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-16 17:44 [ 00/69] 3.10.17-stable review Greg Kroah-Hartman
2013-10-16 17:44 ` [ 01/69] ALSA: snd-usb-usx2y: remove bogus frame checks Greg Kroah-Hartman
2013-10-16 17:44 ` [ 02/69] ALSA: hda - hdmi: Fix channel map switch not taking effect Greg Kroah-Hartman
2013-10-16 17:44 ` [ 03/69] ALSA: hda - Add fixup for ASUS N56VZ Greg Kroah-Hartman
2013-10-16 17:44 ` [ 04/69] ALSA: hda - Fix microphone for Sony VAIO Pro 13 (Haswell model) Greg Kroah-Hartman
2013-10-16 17:44 ` [ 05/69] random: run random_int_secret_init() run after all late_initcalls Greg Kroah-Hartman
2013-10-16 17:44 ` [ 06/69] vfs: allow O_PATH file descriptors for fstatfs() Greg Kroah-Hartman
2013-10-16 17:44 ` [ 07/69] i2c: omap: Clear ARDY bit twice Greg Kroah-Hartman
2013-10-16 17:44 ` [ 08/69] hwmon: (applesmc) Always read until end of data Greg Kroah-Hartman
2013-10-16 17:44 ` [ 09/69] Btrfs: use right root when checking for hash collision Greg Kroah-Hartman
2013-10-16 17:44 ` [ 10/69] ext4: fix memory leak in xattr Greg Kroah-Hartman
2013-10-16 17:44 ` [ 11/69] KVM: PPC: Book3S HV: Fix typo in saving DSCR Greg Kroah-Hartman
2013-10-16 17:44 ` [ 12/69] parisc: fix interruption handler to respect pagefault_disable() Greg Kroah-Hartman
2013-10-16 17:44 ` [ 13/69] ARM: Fix the world famous typo with is_gate_vma() Greg Kroah-Hartman
2013-10-16 17:44 ` [ 14/69] ARC: Setup Vector Table Base in early boot Greg Kroah-Hartman
2013-10-16 17:44 ` [ 15/69] ARC: SMP failed to boot due to missing IVT setup Greg Kroah-Hartman
2013-10-16 17:44 ` [ 16/69] ARC: Fix __udelay calculation Greg Kroah-Hartman
2013-10-16 17:44 ` [ 17/69] ARC: Handle zero-overhead-loop in unaligned access handler Greg Kroah-Hartman
2013-10-16 17:44 ` [ 18/69] ARC: Fix 32-bit wrap around in access_ok() Greg Kroah-Hartman
2013-10-16 17:44 ` [ 19/69] ARC: Workaround spinlock livelock in SMP SystemC simulation Greg Kroah-Hartman
2013-10-16 17:44 ` [ 20/69] ARC: Fix signal frame management for SA_SIGINFO Greg Kroah-Hartman
2013-10-16 17:44 ` [ 21/69] ARC: Ignore ptrace SETREGSET request for synthetic register "stop_pc" Greg Kroah-Hartman
2013-10-16 17:44 ` [ 22/69] watchdog: ts72xx_wdt: locking bug in ioctl Greg Kroah-Hartman
2013-10-16 17:44 ` [ 23/69] compiler/gcc4: Add quirk for asm goto miscompilation bug Greg Kroah-Hartman
2013-10-16 17:44 ` [ 24/69] ALSA: hda - Fix mono speakers and headset mic on Dell Vostro 5470 Greg Kroah-Hartman
2013-10-16 17:44 ` [ 25/69] cope with potentially long ->d_dname() output for shmem/hugetlb Greg Kroah-Hartman
2013-10-16 17:44 ` [ 26/69] drm/i915: Only apply DPMS to the encoder if enabled Greg Kroah-Hartman
2013-10-16 17:44 ` [ 27/69] drm/radeon: forever loop on error in radeon_do_test_moves() Greg Kroah-Hartman
2013-10-16 17:44 ` [ 28/69] drm/radeon: fix typo in CP DMA register headers Greg Kroah-Hartman
2013-10-16 17:44 ` [ 29/69] drm/radeon: fix hw contexts for SUMO2 asics Greg Kroah-Hartman
2013-10-16 17:44 ` [ 30/69] ipc: move rcu lock out of ipc_addid Greg Kroah-Hartman
2013-10-16 17:44 ` [ 31/69] ipc: introduce ipc object locking helpers Greg Kroah-Hartman
2013-10-16 17:44 ` [ 32/69] ipc: close open coded spin lock calls Greg Kroah-Hartman
2013-10-16 17:44 ` [ 33/69] ipc: move locking out of ipcctl_pre_down_nolock Greg Kroah-Hartman
2013-10-16 17:44 ` [ 34/69] ipc,msg: shorten critical region in msgctl_down Greg Kroah-Hartman
2013-10-16 17:44 ` [ 35/69] ipc,msg: introduce msgctl_nolock Greg Kroah-Hartman
2013-10-16 17:44 ` [ 36/69] ipc,msg: introduce lockless functions to obtain the ipc object Greg Kroah-Hartman
2013-10-16 17:44 ` [ 37/69] ipc,msg: make msgctl_nolock lockless Greg Kroah-Hartman
2013-10-16 17:44 ` [ 38/69] ipc,msg: shorten critical region in msgsnd Greg Kroah-Hartman
2013-10-16 17:44 ` [ 39/69] ipc,msg: shorten critical region in msgrcv Greg Kroah-Hartman
2013-10-16 17:44 ` [ 40/69] ipc: remove unused functions Greg Kroah-Hartman
2013-10-16 17:44 ` [ 41/69] ipc/util.c, ipc_rcu_alloc: cacheline align allocation Greg Kroah-Hartman
2013-10-16 17:44 ` [ 42/69] ipc/sem.c: cacheline align the semaphore structures Greg Kroah-Hartman
2013-10-16 17:44 ` [ 43/69] ipc/sem: separate wait-for-zero and alter tasks into seperate queues Greg Kroah-Hartman
2013-10-16 17:44 ` [ 44/69] ipc/sem.c: always use only one queue for alter operations Greg Kroah-Hartman
2013-10-16 17:44 ` [ 45/69] ipc/sem.c: replace shared sem_otime with per-semaphore value Greg Kroah-Hartman
2013-10-16 17:44 ` [ 46/69] ipc/sem.c: rename try_atomic_semop() to perform_atomic_semop(), docu update Greg Kroah-Hartman
2013-10-16 17:44 ` [ 47/69] ipc/msg.c: Fix lost wakeup in msgsnd() Greg Kroah-Hartman
2013-10-16 17:44 ` [ 48/69] ipc,shm: introduce lockless functions to obtain the ipc object Greg Kroah-Hartman
2013-10-16 17:44 ` [ 49/69] ipc,shm: shorten critical region in shmctl_down Greg Kroah-Hartman
2013-10-16 17:44 ` [ 50/69] ipc: drop ipcctl_pre_down Greg Kroah-Hartman
2013-10-16 17:45 ` [ 51/69] ipc,shm: introduce shmctl_nolock Greg Kroah-Hartman
2013-10-16 17:45 ` [ 52/69] ipc,shm: make shmctl_nolock lockless Greg Kroah-Hartman
2013-10-16 17:45 ` [ 53/69] ipc,shm: shorten critical region for shmctl Greg Kroah-Hartman
2013-10-16 17:45 ` [ 54/69] ipc,shm: cleanup do_shmat pasta Greg Kroah-Hartman
2013-10-16 17:45 ` [ 55/69] ipc,shm: shorten critical region for shmat Greg Kroah-Hartman
2013-10-16 17:45 ` [ 56/69] ipc: rename ids->rw_mutex Greg Kroah-Hartman
2013-10-16 17:45 ` [ 57/69] ipc,msg: drop msg_unlock Greg Kroah-Hartman
2013-10-16 17:45 ` [ 58/69] ipc: document general ipc locking scheme Greg Kroah-Hartman
2013-10-16 17:45 ` [ 59/69] ipc, shm: guard against non-existant vma in shmdt(2) Greg Kroah-Hartman
2013-10-16 17:45 ` [ 60/69] ipc: drop ipc_lock_by_ptr Greg Kroah-Hartman
2013-10-16 17:45 ` [ 61/69] ipc, shm: drop shm_lock_check Greg Kroah-Hartman
2013-10-16 17:45 ` [ 62/69] ipc: drop ipc_lock_check Greg Kroah-Hartman
2013-10-16 17:45 ` [ 63/69] ipc: fix race with LSMs Greg Kroah-Hartman
2013-10-16 17:45 ` [ 64/69] ipc/sem.c: fix race in sem_lock() Greg Kroah-Hartman
2013-10-16 17:45 ` [ 65/69] ipc/sem.c: optimize sem_lock() Greg Kroah-Hartman
2013-10-16 17:45 ` [ 66/69] ipc/sem.c: synchronize the proc interface Greg Kroah-Hartman
2013-10-16 17:45 ` [ 67/69] ipc/sem.c: update sem_otime for all operations Greg Kroah-Hartman
2013-10-16 17:45 ` [ 68/69] ipc,msg: prevent race with rmid in msgsnd,msgrcv Greg Kroah-Hartman
2013-10-16 17:45 ` Greg Kroah-Hartman [this message]
2013-10-16 22:11 ` [ 00/69] 3.10.17-stable review Guenter Roeck
2013-10-17  1:07   ` Greg Kroah-Hartman
2013-10-17 16:50 ` Shuah Khan

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=20131016174321.349642916@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=hpa@linux.intel.com \
    --cc=linn@hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul.gortmaker@windriver.com \
    --cc=penberg@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=yinghai@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).