From patchwork Sun Apr 29 11:06:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134662 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp2663700lji; Sun, 29 Apr 2018 04:06:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoLEjSJBp83olspbeScRlsoqjCJkEE6qXIWzBZMaSkMjxZOJ2gAp22ur4WZCnhcczcTc4wV X-Received: by 10.98.57.156 with SMTP id u28mr8522743pfj.95.1525000007392; Sun, 29 Apr 2018 04:06:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525000007; cv=none; d=google.com; s=arc-20160816; b=OcwOQYwj1ArZ6Frx3Le5kMBc68J+/Sbfcn8yKVKMLfhuTo5JBo22sGPIkgFuDOBZHr cDuekpO+UoAYICp8k11XRYWGF6Cl5aShLTQQRCVW9cFhE1qhoYX2MzEb/rXrjKkEbqH9 Kk25dIDgbq92WrZGn2oy2mKYgPqb5Nur9bIJ2UurpNKEc8H9l58qnGObIC9B3Wa9Z10e V5OLhDKf1yyRHdpnJ3VgnK/1LYD6RSQcLhU6ovRKR4iBgmICxkXP+FeOQHCib2l+arTl 2H2BmuxQiC0LomjZIEUTzHWm2jKiEMNKyZY/gR/OY3rEvs5lHj7bPDBR3keFyBLjZuAq /Rlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=NRBdI/TLBiUCtES3AhqlixTdIjE6BLtmoIRgeZIVkGY=; b=OkwVSYQUzhksk+pWCObn+qCB8tDdb62Pw87FLd8fujtO6F1bI6/hWfNwBrSgSoSP8G angZx2c7IN6k2UTQ83Qz9SELCkA40FJir2GlklVIPelo/kR6dan1HCzljBjpdsBPocar SwF1yDwL+xc9O35jYbS7zXbBthADoCInVOAZ5py8qa3FKoyr/leFd1er7q2IuZRqpoTy qtqV8VLOanM88/Y3cONkWcIrkLHUgFZQIwYXihy7OxQd3BAjE93yjN+8ZeR/mt9xle6I gKQiBiEFfVjipCIfBY+4X8tNRm7FlyqvEJ9GwvOrWubVS4gswaNuKTSpxKRGnQMTKL+P FUcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Mx20oTuQ; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z1-v6si5369654plo.263.2018.04.29.04.06.47; Sun, 29 Apr 2018 04:06:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Mx20oTuQ; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752895AbeD2LGq (ORCPT + 2 others); Sun, 29 Apr 2018 07:06:46 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:40815 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752864AbeD2LGp (ORCPT ); Sun, 29 Apr 2018 07:06:45 -0400 Received: by mail-wr0-f193.google.com with SMTP id v60-v6so5527845wrc.7 for ; Sun, 29 Apr 2018 04:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wZm8+qDlhYAaGmAENHwDDzLI1CHyjII/6z4l9kThx7g=; b=Mx20oTuQxGvez2gnr6L2cjJjfoosRC3JHI+AVVng5yaiPx03k0zlsuzYTdQ1ovD3SG YI7mun71OcStuQaFUlT54ItXnwGbEUSvc/4phGLb7bqj1krNSonyE7OeYadGmXZJZfkn 1WL/B2dcfy9FI6Q3Nri1RxtHlre1EhIVzZ1Fg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wZm8+qDlhYAaGmAENHwDDzLI1CHyjII/6z4l9kThx7g=; b=EcM7EfStWONyAGHF0lQ4RPSgDMv7/0D6JIc4H/f5fOmbm3ReRMoyADkXLl9N6Z7Uol /9YsU3Q1IDBql5EIPQH0MC+09zCDFAqjchASnpLOciDkkMGHHDiMMuNwzo0kOnhNQfsA nqwRY+L3YqYiRCegU1KBipVJ9GS2LiYP3HnOkyubDW/Tmgwlny5BZVsPgI3bR6P7Gl3n LOvPiNF89xQ7B5K3bYCXmge+Hf8tZufyrDiAHnjv9qxdCfvP7dT+/zePiUDXYJGQAyUR c4n0OASNUwgrTT0ttla3xuN2qbT0fogUx1Z7x+NNPt/LX+IYtRAHPbHc0XUND/KA9JVU hrAw== X-Gm-Message-State: ALQs6tDvuWqs2/f91T9gzxSAcTzTVyo8hPhseDhXqAIA1HTQMqWAg6uj ZABa8xVapM7Gb54KBZ0Qi06AZg== X-Received: by 2002:adf:984c:: with SMTP id v70-v6mr6283562wrb.100.1525000004708; Sun, 29 Apr 2018 04:06:44 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id a13-v6sm4783275wrc.19.2018.04.29.04.06.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Apr 2018 04:06:43 -0700 (PDT) From: Ard Biesheuvel To: mingo@kernel.org, hdegoede@redhat.com, linux-efi@vger.kernel.org Cc: lukas@wunner.de, Ard Biesheuvel Subject: [PATCH v4 1/4] efi: fix efi_pci_io_protocol32 prototype for mixed mode Date: Sun, 29 Apr 2018 13:06:20 +0200 Message-Id: <20180429110623.13949-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180429110623.13949-1-ard.biesheuvel@linaro.org> References: <20180429110623.13949-1-ard.biesheuvel@linaro.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Mixed mode allows a kernel built for x86_64 to interact with 32-bit EFI firmware, but requires us to define all struct definitions carefully when it comes to pointer sizes. efi_pci_io_protocol32 currently uses a void* for the 'romimage' field, which will be interpreted as a 64-bit field on such kernels, potentially resulting in bogus memory references and subsequent crashes. Cc: Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/eboot.c | 6 ++++-- include/linux/efi.h | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index 47d3efff6805..09f36c0d9d4f 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -163,7 +163,8 @@ __setup_efi_pci32(efi_pci_io_protocol_32 *pci, struct pci_setup_rom **__rom) if (status != EFI_SUCCESS) goto free_struct; - memcpy(rom->romdata, pci->romimage, pci->romsize); + memcpy(rom->romdata, (void *)(unsigned long)pci->romimage, + pci->romsize); return status; free_struct: @@ -269,7 +270,8 @@ __setup_efi_pci64(efi_pci_io_protocol_64 *pci, struct pci_setup_rom **__rom) if (status != EFI_SUCCESS) goto free_struct; - memcpy(rom->romdata, pci->romimage, pci->romsize); + memcpy(rom->romdata, (void *)(unsigned long)pci->romimage, + pci->romsize); return status; free_struct: diff --git a/include/linux/efi.h b/include/linux/efi.h index f1b7d68ac460..3016d8c456bc 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -395,8 +395,8 @@ typedef struct { u32 attributes; u32 get_bar_attributes; u32 set_bar_attributes; - uint64_t romsize; - void *romimage; + u64 romsize; + u32 romimage; } efi_pci_io_protocol_32; typedef struct { @@ -415,8 +415,8 @@ typedef struct { u64 attributes; u64 get_bar_attributes; u64 set_bar_attributes; - uint64_t romsize; - void *romimage; + u64 romsize; + u64 romimage; } efi_pci_io_protocol_64; typedef struct {