From patchwork Tue May 9 21:00:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9718969 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 40EAD60237 for ; Tue, 9 May 2017 21:00:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 329662849A for ; Tue, 9 May 2017 21:00:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2737C284D4; Tue, 9 May 2017 21:00:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AB9C2849A for ; Tue, 9 May 2017 21:00:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750733AbdEIVAz (ORCPT ); Tue, 9 May 2017 17:00:55 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:36023 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750720AbdEIVAy (ORCPT ); Tue, 9 May 2017 17:00:54 -0400 Received: by mail-pf0-f169.google.com with SMTP id m17so5633628pfg.3 for ; Tue, 09 May 2017 14:00:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=OD/o9EP9TgeLpCEtbxLOHtL8y8zDv4bOY4X/KbEgncY=; b=c4ZvqSlt+2qrRenN6AvnVSPc7qhpznd3JxDbl9PEbF93qO9VxKx8zWxigLan4dkKK8 d7n0cVzuqHMyuTAJwVP7Oli6kPpIdFltPPDtMSJ6dbWB5Fkm9jma7P1aH+xz7k+LBUg3 4SVbfQ2i57UJeNK4eqlbZJA+OD8XgZcBp9HGs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=OD/o9EP9TgeLpCEtbxLOHtL8y8zDv4bOY4X/KbEgncY=; b=l6WeLc7U6iGjBernJNYV+h/cKLgwSXmv9qlma/W7QYJ3NrxZYMZprHdn4Q0qHAaG/c wzvBUiv5RjtHslmgqqHZwveYWGJ8EmcOOSPP2fMTLdN1ODpZrkZmI4tR3lAGQZbsvhlK wwVkry2q4gJhTedVFB5frPaeljvAGXuBBg4L7DkFzbMR5pDkeGG+O/une7TaCOm2trLd jJL6gpHPgKU65QlnpzQitZb8gSfJMzRpNUzRqjsrIQQQUdLyoxIIHNg3cUBOQ5sFpE7n 94F67WcUJumvYWpbGDVz2YvYlRCwvU8K5a12iIA1lVkxDKiL12PaPcuXvXwArEoosYp7 8FFA== X-Gm-Message-State: AODbwcCBztUHyngzY9LFwOWytMydUJdBrJsha/FhPbwsfUuvoUXaaHF9 xNyow33HsbfiOGQZ X-Received: by 10.98.88.4 with SMTP id m4mr2119977pfb.41.1494363653489; Tue, 09 May 2017 14:00:53 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id y190sm1408910pgd.25.2017.05.09.14.00.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 May 2017 14:00:52 -0700 (PDT) Date: Tue, 9 May 2017 14:00:51 -0700 From: Kees Cook To: linux-kernel@vger.kernel.org Cc: "Rafael J. Wysocki" , Pavel Machek , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-pm@vger.kernel.org, Daniel Micay Subject: [PATCH] x86/power/64: Use char arrays for asm function names Message-ID: <20170509210051.GA36504@beast> MIME-Version: 1.0 Content-Disposition: inline Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This switches the hibernate_64.S function names into character arrays to match other areas of the kernel where this is done (e.g., linker scripts). Specifically this fixes a compile-time error noticed by the future CONFIG_FORTIFY_SOURCE routines that complained about PAGE_SIZE being copied out of the "single byte" core_restore_code variable. Additionally drops the "acpi_save_state_mem" exern which does not appear to be used anywhere else in the kernel. Cc: Daniel Micay Signed-off-by: Kees Cook Acked-by: Rafael J. Wysocki Acked-by: Ingo Molnar --- arch/x86/include/asm/suspend_64.h | 5 ++--- arch/x86/power/hibernate_64.c | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/suspend_64.h b/arch/x86/include/asm/suspend_64.h index 6136a18152af..2bd96b4df140 100644 --- a/arch/x86/include/asm/suspend_64.h +++ b/arch/x86/include/asm/suspend_64.h @@ -42,8 +42,7 @@ struct saved_context { set_debugreg((thread)->debugreg##register, register) /* routines for saving/restoring kernel state */ -extern int acpi_save_state_mem(void); -extern char core_restore_code; -extern char restore_registers; +extern char core_restore_code[]; +extern char restore_registers[]; #endif /* _ASM_X86_SUSPEND_64_H */ diff --git a/arch/x86/power/hibernate_64.c b/arch/x86/power/hibernate_64.c index 6a61194ffd58..2cc419990ab7 100644 --- a/arch/x86/power/hibernate_64.c +++ b/arch/x86/power/hibernate_64.c @@ -147,7 +147,7 @@ static int relocate_restore_code(void) if (!relocated_restore_code) return -ENOMEM; - memcpy((void *)relocated_restore_code, &core_restore_code, PAGE_SIZE); + memcpy((void *)relocated_restore_code, core_restore_code, PAGE_SIZE); /* Make the page containing the relocated code executable */ pgd = (pgd_t *)__va(read_cr3()) + pgd_index(relocated_restore_code); @@ -292,8 +292,8 @@ int arch_hibernation_header_save(void *addr, unsigned int max_size) if (max_size < sizeof(struct restore_data_record)) return -EOVERFLOW; - rdr->jump_address = (unsigned long)&restore_registers; - rdr->jump_address_phys = __pa_symbol(&restore_registers); + rdr->jump_address = (unsigned long)restore_registers; + rdr->jump_address_phys = __pa_symbol(restore_registers); rdr->cr3 = restore_cr3; rdr->magic = RESTORE_MAGIC;