Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1097908pxu; Wed, 6 Jan 2021 12:11:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHV3NXsDItpVG0fph4HnafgJ0AzJCkrdEjpqf0PioQpaGKjQGi8y4dJCVq2Cj+91OBKMuc X-Received: by 2002:a17:906:3a0d:: with SMTP id z13mr3919072eje.2.1609963884522; Wed, 06 Jan 2021 12:11:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609963884; cv=none; d=google.com; s=arc-20160816; b=1HAoMNDpppZyHrfR04GYHAjv9tLbFokH8DB/UXGECqh3DBZKFkp68F0ileaUXl0ic9 hY64T1EnaWu89ETOMN099KAv7S2dlqmZ7crAzpbP91hgddlRLvHGAtG9KqSF63/vDkLE lcyZC/zmliAfBcj84DkW+nkjFeVHKHhhH0RRWfwsf/TUoAeqBuGrzclQXKnVEIubuLWi HTPPRC8C8bq/+Mr2RStX2//mNm7j4djNNcE7ZYPD0Oa4PC5lZpwrtXkW6aj6FcBUQ/a9 yEHmImWIYbhFST7bj3N4+fuW4+Ps6cNbzt5cYLdCsABHMkQPo6RVreBbov2NJUHxGr0i 9oug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:reply-to:cc:from:to :dkim-signature:date; bh=6daANB2TdyPWX84b10kSOB7FgmMFj+I2EXYLQzC8gJ4=; b=OeTFrz1yeo8kl7p7Yeuk2dlH3GWnb1yONoju2agK/cCuaqfEr/jSh0jUUXGpd6OyAd 0VhdofBTH6b+P7m4fHTWWxy72P5H+mx3tKC+wEy4Py41TRSN7hfUl/tUnKQ3ELk5MqwC +BNxBgS21BeOwPnPTa5KcgPaaVNJ+yfO3xV4DnA/dAHewBOfsXJNp1W/1V9Xg8Gv05K7 s4G8lI9BelzfAtMuwp1AT0MSVfzJ9anY8PL2zMz0SsKm0klAPAhXaj2qO8+Yd1oBTNsV iwNF3oiU4AUB5z+Ph4r0QGXKaAvui5ukX5pzc7tzIoyK7U3Br17HMGi8ilG2evWReR2b y1eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=TkLX+2cY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs12si1255643ejb.127.2021.01.06.12.11.01; Wed, 06 Jan 2021 12:11:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=TkLX+2cY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726831AbhAFUJc (ORCPT + 99 others); Wed, 6 Jan 2021 15:09:32 -0500 Received: from mail2.protonmail.ch ([185.70.40.22]:23915 "EHLO mail2.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725822AbhAFUJc (ORCPT ); Wed, 6 Jan 2021 15:09:32 -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 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 =09=09*(.pdr) =09=09*(.reginfo) =09} + +=09/* +=09 * Sections that should stay zero sized, which is safer to +=09 * explicitly check instead of blindly discarding. +=09 */ + +=09.got : { +=09=09*(.got) +=09=09*(.igot.*) +=09} +=09ASSERT(SIZEOF(.got) =3D=3D 0, "Unexpected GOT entries detected!") + +=09.got.plt (INFO) : { +=09=09*(.got.plt) +=09} +=09ASSERT(SIZEOF(.got.plt) =3D=3D 0, "Unexpected GOT/PLT entries detected!= ") + +=09.plt : { +=09=09*(.plt) +=09=09*(.plt.*) +=09=09*(.iplt) +=09} +=09ASSERT(SIZEOF(.plt) =3D=3D 0, "Unexpected run-time procedure linkages d= etected!") + +=09.rel.dyn : { +=09=09*(.rel.*) +=09=09*(.rel_*) +=09} +=09ASSERT(SIZEOF(.rel.dyn) =3D=3D 0, "Unexpected run-time relocations (.re= l) detected!") + +=09.rela.dyn : { +=09=09*(.rela.*) +=09=09*(.rela_*) +=09} +=09ASSERT(SIZEOF(.rela.dyn) =3D=3D 0, "Unexpected run-time relocations (.r= ela) detected!") } --=20 2.30.0