Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934734AbbGVPcy (ORCPT ); Wed, 22 Jul 2015 11:32:54 -0400 Received: from www.linutronix.de ([62.245.132.108]:39675 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934429AbbGVPcx (ORCPT ); Wed, 22 Jul 2015 11:32:53 -0400 From: Sebastian Andrzej Siewior To: Matt Fleming Cc: x86@kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Andrzej Siewior Subject: [PATCH] x86/mm, efi: Check for valid image type Date: Wed, 22 Jul 2015 17:32:44 +0200 Message-Id: <1437579164-20176-1-git-send-email-bigeasy@linutronix.de> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001,URIBL_BLOCKED=0.001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1811 Lines: 51 I usually see |Ignoring BGRT: failed to allocate memory for image (wanted 264301314 bytes) |Ignoring BGRT: failed to allocate memory for image (wanted 3925872891 bytes) sometimes I get |------------[ cut here ]------------ |WARNING: CPU: 0 PID: 0 at mm/early_ioremap.c:136 __early_ioremap.constprop.0+0x113/0x1d3() … | [] __early_ioremap.constprop.0+0x113/0x1d3 | [] early_ioremap+0x13/0x15 | [] efi_bgrt_init+0x1e2/0x27d … now and then. The data behind that pointer changes on each boot because nobody preserves the content across kexec. Signed-off-by: Sebastian Andrzej Siewior --- I don't know much about the requirement of having the .bmp in memory all the time. Would it be a bad thing to compress the bmp and uncompress on cat from userland? In my case the bmp has 272 KiB and LZO gets it down to 12KiB, XZ 7.4KiB. arch/x86/platform/efi/efi-bgrt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/platform/efi/efi-bgrt.c b/arch/x86/platform/efi/efi-bgrt.c index d7f997f7c26d..59710f0875bb 100644 --- a/arch/x86/platform/efi/efi-bgrt.c +++ b/arch/x86/platform/efi/efi-bgrt.c @@ -79,6 +79,10 @@ void __init efi_bgrt_init(void) memcpy_fromio(&bmp_header, image, sizeof(bmp_header)); if (ioremapped) early_iounmap(image, sizeof(bmp_header)); + if (bmp_header.id != 0x4d42) { + pr_err("BGRT: Not a valid BMP file.\n"); + return; + } bgrt_image_size = bmp_header.size; bgrt_image = kmalloc(bgrt_image_size, GFP_KERNEL | __GFP_NOWARN); -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/