From patchwork Wed Jun 20 04:31:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ethan Tuttle X-Patchwork-Id: 10475937 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 E2B2960210 for ; Wed, 20 Jun 2018 04:32:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBCAB28E9B for ; Wed, 20 Jun 2018 04:32:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C79C128ECB; Wed, 20 Jun 2018 04:32:15 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ACDD228F24 for ; Wed, 20 Jun 2018 04:31:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=/rOtKhdGLVkOjz2NwyToUth/4b0LLey0f8dkUARWP/g=; b=TK7 uFqWgSDi8HX02+l41fAXTIAK2ocxwgbjxvZaiTb9mBpO9ZLMRjY5n7rK5ifKkISjnTMs8aFWG4fYD t9zHZhn2wVezXP4S04amfDGK/nkaWY50Wps2WqsIfDYQ5L5BBE9kjPdrMlidRjqlkAQag7WzMjRFW 6X91Tp4VHlZ2HFSl4HXL6mLXqinAdzF/L22Lvh5ciPfIf7oqiuYfdUdBen98C6pSEVK8cx1Le9b5g kLgx9UbHnKp81i9/5byUQ9A6O001aiJx9UXGQm5uuz2tnkBEiky4vz4NDAo1kswcsUlg3l7Tgv2mO SsiM9zyhNFzUHlwCsitRBy15mGS7MyQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVUmM-0000K5-Vz; Wed, 20 Jun 2018 04:31:34 +0000 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVUmJ-0000Ii-6i for linux-arm-kernel@lists.infradead.org; Wed, 20 Jun 2018 04:31:32 +0000 Received: by mail-pf0-x242.google.com with SMTP id c22-v6so943224pfi.2 for ; Tue, 19 Jun 2018 21:31:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ethantuttle-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=4WdIOnYBk/gaJ81rghZ0C9OItTocO8iZGa6//nyJE2o=; b=AahoqSUYDiR08YKkIKwdXW+22BkOiuHrUtjEZl5Iplo8+hlQgPZhhDJfP3tJhJpfsO 6O5YuU7djFgEdW5+hme46rDIBuPbzB+HWSwzN5jevVnnp7mrJsisO70yEK+TAegVaAK7 KhM4qo91o56Iobk/ATrQIVOUrSan18wDbliwXl0eGGh0kbyxWgypkRuSUK9n6UEOCbMJ KOgtP1ZJUnzwoBrcHLU6K2d7Td7NzX4deFqMK/VoHLOA0bioihmBMtFXVs/kFAhgX7Qf vqfX0qUyw5DCj8cS0ddZPgZ0pc5V1S09WD1oc2jCnlJSPdHYokHxYX/cZfyS+Tcjg0Oc 63sg== 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; bh=4WdIOnYBk/gaJ81rghZ0C9OItTocO8iZGa6//nyJE2o=; b=oD9TJZShPzIuRY1mcwNsJvLHRdlZZ+Pr84gj2EnkPtsxxA/DDu7JZLR5qwHJyLGw1u nvBFXUOBYpwlcBkE+ZYX2vHW70zm4YnQvU4blS1i8/DbqGo4PvT69FWYLPh8OJbtuBcE CwmaKlP9YimwaWcg8YTqdbEVUrFd3ki0UFetKFE4dOukO70bk9tM+TKkKLPeIJI3H0XN R+dgIeydJFUqnhmnMmpC/ulUAgZXff5YLifFll1FW4OeUqdxmN77o2v2eNZh0foZbYCG CeTAqgMkNWhCq7z+XTAC+FDMf9uvvAA6NqGcpMLT06TcVewIynG2dM0EQntb/4x6Hrsh dXEQ== X-Gm-Message-State: APt69E1rdvyTj+VPgZWsMgFGdew19nemzQSe6oH5ayDWVHKrwE3xANaa k8OWiczrBbfZzkyvbqZ9cYQfXg== X-Google-Smtp-Source: ADUXVKJllbDxn99O3wEtGRggpFFz2AzoMl5maO5pKJsd82vRWONpRf51dFc9EmEx8Wnr1uomDVGk0A== X-Received: by 2002:a63:780b:: with SMTP id t11-v6mr17115738pgc.91.1529469079530; Tue, 19 Jun 2018 21:31:19 -0700 (PDT) Received: from arch.hsd1.ca.comcast.net (c-67-169-71-69.hsd1.ca.comcast.net. [67.169.71.69]) by smtp.gmail.com with ESMTPSA id j23-v6sm1544432pfi.137.2018.06.19.21.31.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Jun 2018 21:31:18 -0700 (PDT) From: Ethan Tuttle To: Subject: [PATCH] ARM: mvebu: declare asm symbols as character arrays in pmsu.c Date: Tue, 19 Jun 2018 21:31:08 -0700 Message-Id: <20180620043109.1190-1-ethan@ethantuttle.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180619_213131_263689_BECB779C X-CRM114-Status: GOOD ( 12.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Jason Cooper , Gregory Clement , Russell King , linux-kernel@vger.kernel.org, Ethan Tuttle , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP With CONFIG_FORTIFY_SOURCE, memcpy uses the declared size of operands to detect buffer overflows. If src or dest is declared as a char, attempts to copy more than byte will result in a fortify_panic(). Address this problem in mvebu_setup_boot_addr_wa() by declaring mvebu_boot_wa_start and mvebu_boot_wa_end as character arrays. Also remove a couple addressof operators to avoid "arithmetic on pointer to an incomplete type" compiler error. See commit 54a7d50b9205 ("x86: mark kprobe templates as character arrays, not single characters") for a similar fix. Fixes "detected buffer overflow in memcpy" error during init on some mvebu systems (armada-370-xp, armada-375): (fortify_panic) from (mvebu_setup_boot_addr_wa+0xb0/0xb4) (mvebu_setup_boot_addr_wa) from (mvebu_v7_cpu_pm_init+0x154/0x204) (mvebu_v7_cpu_pm_init) from (do_one_initcall+0x7c/0x1a8) (do_one_initcall) from (kernel_init_freeable+0x1bc/0x254) (kernel_init_freeable) from (kernel_init+0x8/0x114) (kernel_init) from (ret_from_fork+0x14/0x2c) Signed-off-by: Ethan Tuttle Tested-by: Ethan Tuttle --- arch/arm/mach-mvebu/pmsu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-mvebu/pmsu.c b/arch/arm/mach-mvebu/pmsu.c index 27a78c80e5b1..73d5d72dfc3e 100644 --- a/arch/arm/mach-mvebu/pmsu.c +++ b/arch/arm/mach-mvebu/pmsu.c @@ -116,8 +116,8 @@ void mvebu_pmsu_set_cpu_boot_addr(int hw_cpu, void *boot_addr) PMSU_BOOT_ADDR_REDIRECT_OFFSET(hw_cpu)); } -extern unsigned char mvebu_boot_wa_start; -extern unsigned char mvebu_boot_wa_end; +extern unsigned char mvebu_boot_wa_start[]; +extern unsigned char mvebu_boot_wa_end[]; /* * This function sets up the boot address workaround needed for SMP @@ -130,7 +130,7 @@ int mvebu_setup_boot_addr_wa(unsigned int crypto_eng_target, phys_addr_t resume_addr_reg) { void __iomem *sram_virt_base; - u32 code_len = &mvebu_boot_wa_end - &mvebu_boot_wa_start; + u32 code_len = mvebu_boot_wa_end - mvebu_boot_wa_start; mvebu_mbus_del_window(BOOTROM_BASE, BOOTROM_SIZE); mvebu_mbus_add_window_by_id(crypto_eng_target, crypto_eng_attribute,