From patchwork Fri May 4 05:59:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 134951 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp438169lji; Thu, 3 May 2018 23:02:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpXGlNW9IN9TGbKuu9jdZ3Vb8ThgSl/blw48KoNT3Frvm27Dc3JkrvA1NmZMKBZKFpjA8W0 X-Received: by 2002:a63:7351:: with SMTP id d17-v6mr20778134pgn.297.1525413761924; Thu, 03 May 2018 23:02:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525413761; cv=none; d=google.com; s=arc-20160816; b=DnhOIlE/v/cIV/LfpGpvhjRxqnSNqb3pZ1heXRuKXOX8bj7zNkn4gOpB9s4HOsqStz nTQjI9dcYYHQRqLKjAsQDBwQELWBt5dFgk9HsVmpgUW0DddREcfJjNhblQoVKodl+sTY vnKk5pV7oLyLlrurFSvvcZCwZWMXrrCDfx3C/imXFqc1PWHT38V5Lh9BCeYbp/Crmh3s 2jDnm+7kU/zLKazAxvck2wtQZYPMv4lUnhpt+3c2gVqq1z5k6XLPp5PRcaGpJWCoZA7f 3/isjDSWzuk4Mp41AEpLIAx1AV/wUi8K9isKJlcVBqgPdz0DasMPd2AUK6DwHzoygRCB Wckw== 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=DP4JkgWAtbOlIPVGPptEC9kcOHFugAy9oPZiXyvto8A=; b=aWVdU59cHofsNl50govtnlYSIZzPgdAvZSWd5X+ial6ecQUgd4qfzahwPWb80W126W QKHLf7xgsJQZuAcHR9rtbPkc/BEMbS/IjRlJGhE/TQdEMmSlP73qcvZHDdTusGAA5PPg O5LXwgxP3emfV28prDDrJxGTMKVuhEp/XbbUrXFkKx4nyNsNvd5IGQcTB6azxlZVNtwl iLN7NJ6xOgVqt4zaWP9V2hxlmYus+NZ82l4FgBWoke658+KRW1p4/baA/e0asMzKvyxo RQzSTwwFIZVlwhidZXwS42iY7nwjexophEmD+Tm313sdcPF1sd3rH/vZLpN6/NyIIF7Q 9y3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NSkhG80N; 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 t85-v6si12394942pgb.42.2018.05.03.23.02.41; Thu, 03 May 2018 23:02:41 -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=NSkhG80N; 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 S1751864AbeEDGCk (ORCPT + 2 others); Fri, 4 May 2018 02:02:40 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:38707 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751701AbeEDGB0 (ORCPT ); Fri, 4 May 2018 02:01:26 -0400 Received: by mail-wm0-f68.google.com with SMTP id m198-v6so1808358wmg.3 for ; Thu, 03 May 2018 23:01:25 -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=Xw4qET6IJgIK2jUX6OwtXxw2asqgqhwFZVNmX4x/bfM=; b=NSkhG80NNcpYmGYaTzmnKh0Cbm+kXZA8GHaCIu2BpG5wDoSbx0OQHAd3OKI8E6n+Rw OipWLyZVfXO9iGLCz1kldqsQD+BKdXXYJAAOOCN3bANMyzFHDtwPclJZVUnqVVRmrtbh 5NGhVjouATAORQoKLZ1AB8y8TR08fM/PeC0bY= 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=Xw4qET6IJgIK2jUX6OwtXxw2asqgqhwFZVNmX4x/bfM=; b=DA5d1/W2Wn2bmm39+KJsm0d2el+izMIVllILLgYG7PKx5ao2fmZCfdIdc79aVZMq1v sRKmIS1cAa+LBj7Xy6RYN/meEY2YtAriWsslY4js3qtUi65Pjy5U/AFSutIHvcqBd7lD ry3nghIZUODWKE7eG+69oFZRFkw2ukRwC6rLnykq71bUo1c2/JP7tJa5eSCJ4+/ISL1O ecOu7RxEfORgrPmjwifvXL2/dif37tUohpaC2D5GWAwQ2z8vDArwdM8u/Ti/RBVdd82x xBzXqiFJP5MF2Srtsw0Xg/YISH2ptxpSYxXEBCMrTjU10zU8t4AMZNfwNP6zK1keMjkU FSNw== X-Gm-Message-State: ALQs6tAEjcODvXEuY08+TuDGRyHv2T5DZyxQQoStSov1YJQJUkgX0PKI S+eJkAt0+VBD1oI58OXD5K1iphKzlmg= X-Received: by 10.28.146.196 with SMTP id u187mr12154413wmd.78.1525413684681; Thu, 03 May 2018 23:01:24 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id i30-v6sm32411863wra.38.2018.05.03.23.01.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 23:01:24 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org Subject: [PATCH 12/17] efi: fix efi_pci_io_protocol32 prototype for mixed mode Date: Fri, 4 May 2018 07:59:58 +0200 Message-Id: <20180504060003.19618-13-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504060003.19618-1-ard.biesheuvel@linaro.org> References: <20180504060003.19618-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: Tested-by: Hans de Goede 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 {