Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2065926imm; Thu, 24 May 2018 05:19:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqGayqdvQjzJjjsywt1fvdvLFTISDXfrmifppnStH7gwZQt7Ghx1dcLyfPosQAFf6Vy9isu X-Received: by 2002:a63:43c6:: with SMTP id q189-v6mr5875118pga.123.1527164342473; Thu, 24 May 2018 05:19:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527164342; cv=none; d=google.com; s=arc-20160816; b=VQ3VZxRLNPp3+yFwzgXOAR0g0efHiE/auGitIp+OYP01DNDWGdfbw/2SaKV+yQMZE/ 4TFuV6tDtQIBQ3oR61su6FqXRhQnZ6clgIv6WcDrdifOhjbfiTY3LDZLtX8NLMvwqgbA nKYx/lsckom9/qpTj1kZzqv7uME+WOT0nrgovUoJkxXvibL3QzHtilcPb/0aQJy5Z2Vd x5WCLOlbjf7U0599hLTqfkHPBV+nOA2LA9xxwaFjSjOmtQjaM7pHmYRIZK4bX9PzaitS hMh/SPxrhJ2BwxXJTBRYUQHWk9Vf+eMo1itymMCjInd2472n4tEMWlvrHRaCQYAvggaT UHDg== 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=u+oYDA6KUJ6qMuC7K5whXWkXqK6asaz8BDTk5Oual/Y=; b=Ombr2LwpcZOWWVy4AkOSmReizSj75TxlBb8exNmU/NxagQWRAL4QZsCATsMI6bEkU4 89TUW9BoU2aOyi5JHrBPTOeNKEJcUrBd2cb0f0kcqZxU/gt9dV3Eb4rJCSZQM8oRAI12 olBJEXmEFWTepp1vbaysd7duqCRdWHpULc+BvzU4fgEKWeuKfMMuys4X/jdsmcvzjF2P EGqEWDt7y+/I/WQXkJTZmPc5t5y4yutCvJwBjs6dRkpyHrsk+E/hzNk9BT354N6AyeeL lkDTmwtTGN1wNvOSK0eOA/O9v0zqE9wOn6Z36nC7KB0Bf+hhXXvQ12SiYy6a/hAVC6qZ Rj6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BpVkJvHn; 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 v7-v6si20380249plp.304.2018.05.24.05.18.47; Thu, 24 May 2018 05:19:02 -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=BpVkJvHn; 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 S969864AbeEXMRY (ORCPT + 99 others); Thu, 24 May 2018 08:17:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:53670 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965968AbeEXJl4 (ORCPT ); Thu, 24 May 2018 05:41:56 -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 1232820896; Thu, 24 May 2018 09:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527154915; bh=Ys5Zh56+qNOtUZ16CLwJWWhzBfd94QLnta7gK3lvdgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BpVkJvHntDvU8rNfiGU2dRdalsWPN/HEIOqgZEOihLAUsIoFe7UpvseF24KgGsv9R vk+3sUrJ+cPF4AmO1gc7ZdJz9D/pFQSu31xt4nXUz4Rts8T6sr5SzWOulB3O53FlFu PWhhBk7mwd1y+gj5dQp9SlwTZMIbZAgO2DMlQWLc= 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 3.18 34/45] efi: Avoid potential crashes, fix the struct efi_pci_io_protocol_32 definition for mixed mode Date: Thu, 24 May 2018 11:38:42 +0200 Message-Id: <20180524093125.049014106@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093120.599252450@linuxfoundation.org> References: <20180524093120.599252450@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 3.18-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 @@ -365,7 +365,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: @@ -471,7 +472,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 @@ -360,8 +360,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 { @@ -380,8 +380,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 {