From patchwork Wed Jan 6 20:08:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 358920 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E36BC433E9 for ; Wed, 6 Jan 2021 20:09:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7468023332 for ; Wed, 6 Jan 2021 20:09:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726697AbhAFUJA (ORCPT ); Wed, 6 Jan 2021 15:09:00 -0500 Received: from mail-40133.protonmail.ch ([185.70.40.133]:50666 "EHLO mail-40133.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726090AbhAFUI7 (ORCPT ); Wed, 6 Jan 2021 15:08:59 -0500 Date: Wed, 06 Jan 2021 20:08:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1609963697; bh=hjIccLTNrNOzUNrqAIbTw81FXVcf6wB+LAQsEABOGxY=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=i5a6TJtch6Od01ozZrBiV73uviXZxXdQfPmCCKjPgtoZjLBFlLr4uVJz8CWfOwXVJ 1kA9sw2VpQ5ZM52dVlUsQWtGwJ9vjW3SxqmHdmWoISKy8k1v0M9B9d261QKbXcxnSy PGBo+whYEUl/Ph+Txmsf15Yfn7aaqJwn0in1qoHpN22fwRnDg9yMk15FkiMQfpIJ2o DDNYqwel+FAKjcmoTk1yfKI2OEo/9NT+uoQvJ3ozEpsmvUzktyia6N6w3Fs1BuiL5T yaf2+yyy2mNzbOkVljPxvQxPq/biuNwF0Mc0tQdm4/dFHmiw9oiwMC7pKHb+VuLJxK kcMyDawmaFVsg== To: Thomas Bogendoerfer From: Alexander Lobakin Cc: Alexander Lobakin , Nathan Chancellor , Kees Cook , Fangrui Song , Jiaxun Yang , Alex Smith , Ralf Baechle , Markos Chandras , linux-mips@vger.kernel.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org Reply-To: Alexander Lobakin Subject: [PATCH v2 mips-next 1/4] MIPS: vmlinux.lds.S: add missing PAGE_ALIGNED_DATA() section Message-ID: <20210106200801.31993-1-alobakin@pm.me> In-Reply-To: <20210106200713.31840-1-alobakin@pm.me> References: <20210106200713.31840-1-alobakin@pm.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org MIPS uses its own declaration of rwdata, and thus it should be kept in sync with the asm-generic one. Currently PAGE_ALIGNED_DATA() is missing from the linker script, which emits the following ld warnings: mips-alpine-linux-musl-ld: warning: orphan section `.data..page_aligned' from `arch/mips/kernel/vdso.o' being placed in section `.data..page_aligned' mips-alpine-linux-musl-ld: warning: orphan section `.data..page_aligned' from `arch/mips/vdso/vdso-image.o' being placed in section `.data..page_aligned' Add the necessary declaration, so the mentioned structures will be placed in vmlinux as intended: ffffffff80630580 D __end_once ffffffff80630580 D __start___dyndbg ffffffff80630580 D __start_once ffffffff80630580 D __stop___dyndbg ffffffff80634000 d mips_vdso_data ffffffff80638000 d vdso_data ffffffff80638580 D _gp ffffffff8063c000 T __init_begin ffffffff8063c000 D _edata ffffffff8063c000 T _sinittext -> ffffffff805a4000 D __end_init_task ffffffff805a4000 D __nosave_begin ffffffff805a4000 D __nosave_end ffffffff805a4000 d mips_vdso_data ffffffff805a8000 d vdso_data ffffffff805ac000 D mmlist_lock ffffffff805ac080 D tasklist_lock Fixes: ebb5e78cc634 ("MIPS: Initial implementation of a VDSO") Cc: stable@vger.kernel.org # 4.4+ Signed-off-by: Alexander Lobakin --- arch/mips/kernel/vmlinux.lds.S | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S index 5e97e9d02f98..83e27a181206 100644 --- a/arch/mips/kernel/vmlinux.lds.S +++ b/arch/mips/kernel/vmlinux.lds.S @@ -90,6 +90,7 @@ SECTIONS INIT_TASK_DATA(THREAD_SIZE) NOSAVE_DATA + PAGE_ALIGNED_DATA(PAGE_SIZE) CACHELINE_ALIGNED_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT) READ_MOSTLY_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT) DATA_DATA From patchwork Wed Jan 6 20:08:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 358126 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D076BC433DB for ; Wed, 6 Jan 2021 20:10:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A06F223132 for ; Wed, 6 Jan 2021 20:10:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727164AbhAFUJw (ORCPT ); Wed, 6 Jan 2021 15:09:52 -0500 Received: from mail-02.mail-europe.com ([51.89.119.103]:57576 "EHLO mail-02.mail-europe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727031AbhAFUJv (ORCPT ); Wed, 6 Jan 2021 15:09:51 -0500 Date: Wed, 06 Jan 2021 20:08:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1609963703; bh=gVx8E+xZ9lrHiS0GOCboaARCIQvynUD7BXGkbX/mth4=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=D5BR4ONH0+Jq/LU0r/+wUjKpN7kzcWdAhFr9x7aMgFdq26mi41Ql2zYLn3g4AuR7y /LrjwC+6fobtndVgofP13pV8AsRd5qvnyTf/EMj71FnmDVTDO7MDk1O3T+Y4BNnyxo CSh1T5hd9CvPzhYWfS37WM829VOabqEnMxuz4ROjYgyG7ovyA3bp/6B1LB4rvxOKet UlyHGyu9IXcwWAqczIjrmR9pVtNTCzL1Qs4SuMN8kSiMgRm4yCX5FeCgufBxYrZIrp AfpxXUy5EWWVVuO24Qqga4QaKpYiWWbWYUzF89n+Cht+IGJn/tNQeKSn+XZeEDNz5+ v+0bgIMZtAblg== To: Thomas Bogendoerfer From: Alexander Lobakin Cc: Alexander Lobakin , Nathan Chancellor , Kees Cook , Fangrui Song , Jiaxun Yang , Alex Smith , Ralf Baechle , Markos Chandras , linux-mips@vger.kernel.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org Reply-To: Alexander Lobakin Subject: [PATCH v2 mips-next 2/4] MIPS: vmlinux.lds.S: add ".gnu.attributes" to DISCARDS Message-ID: <20210106200801.31993-2-alobakin@pm.me> In-Reply-To: <20210106200801.31993-1-alobakin@pm.me> References: <20210106200713.31840-1-alobakin@pm.me> <20210106200801.31993-1-alobakin@pm.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Discard GNU attributes at link time as kernel doesn't use it at all. Solves a dozen of the following ld warnings (one per every file): mips-alpine-linux-musl-ld: warning: orphan section `.gnu.attributes' from `arch/mips/kernel/head.o' being placed in section `.gnu.attributes' mips-alpine-linux-musl-ld: warning: orphan section `.gnu.attributes' from `init/main.o' being placed in section `.gnu.attributes' Misc: sort DISCARDS section entries alphabetically. Signed-off-by: Alexander Lobakin --- arch/mips/kernel/vmlinux.lds.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S index 83e27a181206..5d6563970ab2 100644 --- a/arch/mips/kernel/vmlinux.lds.S +++ b/arch/mips/kernel/vmlinux.lds.S @@ -221,9 +221,10 @@ SECTIONS /* ABI crap starts here */ *(.MIPS.abiflags) *(.MIPS.options) + *(.eh_frame) + *(.gnu.attributes) *(.options) *(.pdr) *(.reginfo) - *(.eh_frame) } } From patchwork Wed Jan 6 20:08:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 358127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDCDFC433DB for ; Wed, 6 Jan 2021 20:09:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A56123132 for ; Wed, 6 Jan 2021 20:09:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726329AbhAFUJc (ORCPT ); Wed, 6 Jan 2021 15:09:32 -0500 Received: from mail-40136.protonmail.ch ([185.70.40.136]:25291 "EHLO mail-40136.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbhAFUJb (ORCPT ); Wed, 6 Jan 2021 15:09:31 -0500 Date: Wed, 06 Jan 2021 20:08:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1609963729; bh=6daANB2TdyPWX84b10kSOB7FgmMFj+I2EXYLQzC8gJ4=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=TkLX+2cYrliZ7AE5My32Qk4RkH4BfJnd4n9ged0uMiGci5zxNJ4Sg5qJvIOAL8EbL kqi62uleA/uWUErUm0/NidwKUafttFxjzfYY9TSf9NC2kfG58beRzR/4TAQnSnk03k 6pWmWasRk9Tc5B5rvuK/GHXeXIuW5YJH2Vm7l6TDVtsJ1HXNhomzAy/Ld+VGDusd1f Dk18DmfBMUbjoxb//UNi0/jgTDQW8xBO45uXh3tk5UR/euvz3YAVfAK+RWPE+F4uWJ mMLNFjmcV2Ei9AA+P/dc1VOKE6YVjXiY+WD7JmX4uCMC9QBrKu6GsUKjyhPvV58WJ6 G3UosHlozAnsA== To: Thomas Bogendoerfer From: Alexander Lobakin Cc: Alexander Lobakin , Nathan Chancellor , Kees Cook , Fangrui Song , Jiaxun Yang , Alex Smith , Ralf Baechle , Markos Chandras , linux-mips@vger.kernel.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org Reply-To: Alexander Lobakin Subject: [PATCH v2 mips-next 3/4] MIPS: vmlinux.lds.S: catch bad .got, .plt and .rel.dyn at link time Message-ID: <20210106200801.31993-3-alobakin@pm.me> In-Reply-To: <20210106200801.31993-1-alobakin@pm.me> References: <20210106200713.31840-1-alobakin@pm.me> <20210106200801.31993-1-alobakin@pm.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Catch any symbols placed in .got, .got.plt, .plt, .rel.dyn or .rela.dyn and check for these sections to be zero-sized at link time. At least two of them were noticed in real builds: mips-alpine-linux-musl-ld: warning: orphan section `.rel.dyn' from `init/main.o' being placed in section `.rel.dyn' ld.lld: warning: :(.got) is being placed in '.got' Adopted from x86/kernel/vmlinux.lds.S. Reported-by: Nathan Chancellor # .got Suggested-by: Fangrui Song # .rel.dyn Signed-off-by: Alexander Lobakin --- arch/mips/kernel/vmlinux.lds.S | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S index 5d6563970ab2..05eda9d9a7d5 100644 --- a/arch/mips/kernel/vmlinux.lds.S +++ b/arch/mips/kernel/vmlinux.lds.S @@ -227,4 +227,39 @@ SECTIONS *(.pdr) *(.reginfo) } + + /* + * Sections that should stay zero sized, which is safer to + * explicitly check instead of blindly discarding. + */ + + .got : { + *(.got) + *(.igot.*) + } + ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!") + + .got.plt (INFO) : { + *(.got.plt) + } + ASSERT(SIZEOF(.got.plt) == 0, "Unexpected GOT/PLT entries detected!") + + .plt : { + *(.plt) + *(.plt.*) + *(.iplt) + } + ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!") + + .rel.dyn : { + *(.rel.*) + *(.rel_*) + } + ASSERT(SIZEOF(.rel.dyn) == 0, "Unexpected run-time relocations (.rel) detected!") + + .rela.dyn : { + *(.rela.*) + *(.rela_*) + } + ASSERT(SIZEOF(.rela.dyn) == 0, "Unexpected run-time relocations (.rela) detected!") } From patchwork Wed Jan 6 20:08:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 358919 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C61BC433E6 for ; Wed, 6 Jan 2021 20:09:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2B23C23131 for ; Wed, 6 Jan 2021 20:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727118AbhAFUJi (ORCPT ); Wed, 6 Jan 2021 15:09:38 -0500 Received: from mail-40134.protonmail.ch ([185.70.40.134]:21079 "EHLO mail-40134.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727202AbhAFUJh (ORCPT ); Wed, 6 Jan 2021 15:09:37 -0500 Date: Wed, 06 Jan 2021 20:08:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1609963734; bh=FmvdsZCHCCE79sjLAYIX/gq7paKAr3hB9iXFALHlrb4=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=gt36kiA0CRoN8rChYplX9XqLtn9UKfAR9usnM1uWIFAHUshGzRBlLI+zwggTmGMTj JGbxJM4w/rbrz6YpzayyOgJDU3WL9EPMzb0fdstFh7URQ0qsVgdyosMuc8I2kr6ZLK N+/yCp4qh0juzn28oXa86sRonFMHbUw24GUwou1j1osqEgAqV/hnswyuNFZF9ksmvv JuaB+wbuFWd84McudMSzsxDvg5RiznS19PwJATCwjKJ2ltv4q/FhugFRPtJEl/7voc mV/t33M0CBHvU2KPJcsIFKdJ9yNmLzMYWgRX9Fym1bWK8jyjcr4d62mSdCFvcMKAyp 44mx+EOvo34pw== To: Thomas Bogendoerfer From: Alexander Lobakin Cc: Alexander Lobakin , Nathan Chancellor , Kees Cook , Fangrui Song , Jiaxun Yang , Alex Smith , Ralf Baechle , Markos Chandras , linux-mips@vger.kernel.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org Reply-To: Alexander Lobakin Subject: [PATCH v2 mips-next 4/4] MIPS: select ARCH_WANT_LD_ORPHAN_WARN Message-ID: <20210106200801.31993-4-alobakin@pm.me> In-Reply-To: <20210106200801.31993-1-alobakin@pm.me> References: <20210106200713.31840-1-alobakin@pm.me> <20210106200801.31993-1-alobakin@pm.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Now, after that all the sections are explicitly described and declared in vmlinux.lds.S, we can enable ld orphan warnings to prevent from missing any new sections in future. Signed-off-by: Alexander Lobakin --- arch/mips/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index d68df1febd25..d3e64cc0932b 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -18,6 +18,7 @@ config MIPS select ARCH_USE_QUEUED_SPINLOCKS select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU select ARCH_WANT_IPC_PARSE_VERSION + select ARCH_WANT_LD_ORPHAN_WARN select BUILDTIME_TABLE_SORT select CLONE_BACKWARDS select CPU_NO_EFFICIENT_FFS if (TARGET_ISA_REV < 1)