Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2040434imm; Thu, 24 May 2018 04:59:31 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqMFbt2AJ3J3ipI2VEDxoq6zsdFOFSM2hAcfONDzGQApXVAXLQlr6+4fvvXq2G2QAkk6r6K X-Received: by 2002:a63:6ec6:: with SMTP id j189-v6mr5537994pgc.71.1527163171525; Thu, 24 May 2018 04:59:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527163171; cv=none; d=google.com; s=arc-20160816; b=kjoL6WIZ5P7CyalF2ItmX2NOIL/A5o6soFhOY8+Apzp1bumE4CcEIeiMVaEzlxgnkU 6MRJLCgpc88efow4GUX6edapZtYMAkoXfNBrCmeTpEdI7R9pMc58Cz8Prp3p0v/rF8Rh B93GWfUVyerYjxTJIWI6rPh/BSoPkIkKP/Y/Nh5o/VBI5fn94OfOT6By3e99om+sSfxr A+mVh3Fetci7OBBhqXyL4Doq9CVDCQGojkrm8MIJZt+gWWFt7EHTKRhzWMeZmYklsLx9 NtZKsWc946K2To4bEzF7NV5HpunaGvHzSbXMP3a0VpbXKiNEHbrI5AtZFZV32w8FzVL6 Qktw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=XQ2G5V4FbjFUuuZKjOYye1l3c042pnVZBPxzu8zsOmo=; b=PkyxlsniaYY+OGc0RfwDeytBI4gTImRHU6GtAzxMfj3cvmUAAEfxjUdseShwc0jI6n K18XJfzpBr7mi2WCfPZkgNH7Lm6jm4iTtiE95qDcMnm5M6v//3+5uZPgbxNMK89JyrtC Ij2XJNipwKHKjWNs7wBjea/BnzodnS3TbxgYZ7bnHNwHMVjnPgc2rqb5iM1jn8kmSRuC O9OWjYUeGChKs7xdBwdx6HwrR6cM8q4/7HAIGberR8tKo+GZHdh3y6HV/miO30yIfq6R Xwgb2PxnJHRj5tBcQqLpjb9jV7MIO+/3Emked/ccEc2SsIQTzSFyUuoLhrKdou3kub4W FGwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VqiMA/0O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j18-v6si3125050pgv.575.2018.05.24.04.59.16; Thu, 24 May 2018 04:59:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VqiMA/0O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969493AbeEXL6j (ORCPT + 99 others); Thu, 24 May 2018 07:58:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:56504 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966499AbeEXJpV (ORCPT ); Thu, 24 May 2018 05:45:21 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6414D208C3; Thu, 24 May 2018 09:45:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155120; bh=6ZDzMapBlj+LLI6mmqUI2kB5hQcx6C4LGDVjIl9rHc8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VqiMA/0OLvVJzMHc/9bLz32zH363uyXUAm3pvy2bf+nhr+63ptveSF8Jf9W4I9e52 Ng5ILyd+KDV66KogsnI1d41k5qZbPUoPFMcQLPe7kHekqB+ElKDfOU5y41Q41+ZoV/ Bzb7xmWMXEriQw81FvWt+L0DnjTGEbFFNAdskIzE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , Ard Biesheuvel , Linus Torvalds , Matt Fleming , Peter Zijlstra , Thomas Gleixner , linux-efi@vger.kernel.org, Ingo Molnar Subject: [PATCH 4.4 62/92] efi: Avoid potential crashes, fix the struct efi_pci_io_protocol_32 definition for mixed mode Date: Thu, 24 May 2018 11:38:39 +0200 Message-Id: <20180524093205.251485804@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093159.286472249@linuxfoundation.org> References: <20180524093159.286472249@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ard Biesheuvel commit 0b3225ab9407f557a8e20f23f37aa7236c10a9b1 upstream. 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. 'struct efi_pci_io_protocol_32' 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. Tested-by: Hans de Goede Signed-off-by: Ard Biesheuvel Cc: Cc: Linus Torvalds Cc: Matt Fleming Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20180504060003.19618-13-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/boot/compressed/eboot.c | 6 ++++-- include/linux/efi.h | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -364,7 +364,8 @@ __setup_efi_pci32(efi_pci_io_protocol_32 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: @@ -470,7 +471,8 @@ __setup_efi_pci64(efi_pci_io_protocol_64 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: --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -364,8 +364,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 { @@ -384,8 +384,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 {