Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1105772pxu; Wed, 6 Jan 2021 12:24:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqJbiAcDlEUB5q22FVz61l9gGD76/xLJjwOn95LMilml6ewNcURkpSskervF9BT4ClDOIc X-Received: by 2002:a17:906:3ac3:: with SMTP id z3mr4011439ejd.449.1609964679168; Wed, 06 Jan 2021 12:24:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609964679; cv=none; d=google.com; s=arc-20160816; b=HVGFvPiJ7oskWrkKgFuOTVG4pLKjWdqtM0pxv3TBjq/ZTLP2VMcJDA5sMghBMzTI6D wwelp22o86+xGOeY8rr+z6qHEDjymrul20ivfWuxK5TsZqLsDYZ2S7mtyuKpuvpo6HfP YDladQFEnMoUNJ9kncmnF+KhXI4UEdHqKPlgXR59LMjaA7Nk5ozEyBTuRNtFWDYS8pxA BytvGWlFPWAkg542KN5rVbe/lLNDTHvM+9BqkJ9VXTX2NaBc6BT/JrqZBCxbsw36XdMi Pk9a3ThCqMVD45kGnL3MSu4Xdk9bzy9tCI0QOWWuTv5+Fp3s3HCQvOjsnvHBOlMEWQgI Ifsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=qC3v3aPiZ/ZR6mkFft0a1FWQbrfzrwyrP+icxRFO0Uo=; b=VNxZm2bScXeKQJFjqC+MbuCRRlgUJDqQpxJvlO9LPk0UyTEBNp97yFQEOfqmRrxnqe /p92N13ADvVjnAPRVw/aA5azf/bgjVAHYbnSCe7yrriaygNbRGCzj02sCYbxtJJqeHPk noy/H/hoYTAkXN3h2TZ2o1LgGCwvnjDuU5rIpkaPiEW3mWKrrzId5G5Gg31C7+cfg+0I anpITSA6AhPq0FC1anonW1eYMh1qIQWH5xbpRlN2+YlWzCbEBm5Me92VCD5k7UDYGkTW jkVnSPC6C9rHvqAKhGuh9kDimstgKYuwk7BKtld2EBMkd8vCaRWTdIYIKD03rju4TiJT K1QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=lWjK0Djc; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c6si1305157ejr.727.2021.01.06.12.24.15; Wed, 06 Jan 2021 12:24:39 -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=@google.com header.s=20161025 header.b=lWjK0Djc; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727164AbhAFUWq (ORCPT + 99 others); Wed, 6 Jan 2021 15:22:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726697AbhAFUWp (ORCPT ); Wed, 6 Jan 2021 15:22:45 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CC82C06134C for ; Wed, 6 Jan 2021 12:22:05 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id c12so2349439pfo.10 for ; Wed, 06 Jan 2021 12:22:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qC3v3aPiZ/ZR6mkFft0a1FWQbrfzrwyrP+icxRFO0Uo=; b=lWjK0DjcEVyiNi3dbH0Ml9RlkyjbL9K9DYj+2SjNJeYX2iwhpEZe9jwXg6jN3AhtcU ubhV0ojfjqKfh53UClDjH1ihMibOhcUncz1GYyggB5/JWVc4LlYVRbZX3ph69BvrkgH/ XiWZEB8k3EWGbIajMb+M0D64GI5pLLImOIOKG8Lq09dqPsASsAsNPxBAhLMKK4+WUkYA ugUBdV6yNcdSZOoXT/ZXUJ8JaOmsHRkStyS8UUdENfP6BjKSgGlAbJY2DGwRxJ3C61cb rO3kV4Up6mGKlqqgKjRAwjpRrVnSsEtqiZyp/yax8u/7ZeMSu8HSn01U/5qiW6mvklld I9eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qC3v3aPiZ/ZR6mkFft0a1FWQbrfzrwyrP+icxRFO0Uo=; b=Di1wDHIym5AnkIMv4jKIpquVJ4T34VCYaoMGaZmp0r/Z2JtKqsSNOaMvHjx55ErmaH bCxkYCAxzPTYqT1oSyY3sWgFhmz+51+A6moKaKvymg2XSRAzV0yB1LNa6vivm332rbWs cl7QW6qLPitPBvV2CDhpszJvwWwSIwt3ZeFBcXHLHgAoNgOUb6J0hDq2Ej6hE7G52Md/ yrD5WOf1776yJ6WiTGA4zyjzD2XMNQr/R+ZsDAJF5nljbYtlhbDVl6e4OGvuns96E2Nv rm5GUVb0jBH57jVOh5GDE7MmUrVAhwUhagft4hpRNHfs8TubQ/kU9vpTXW+7jyMB0Mtk agiQ== X-Gm-Message-State: AOAM530Gwgsd68T1h5ePABe+j1kVfOySG+ilg+Tl8OwgbPRPBINDyl+T 4DO6imu9aiCgO2AmEX7j9Zwsxcr962X8wHAUHaDZjQ== X-Received: by 2002:a63:5a08:: with SMTP id o8mr6253893pgb.118.1609964524946; Wed, 06 Jan 2021 12:22:04 -0800 (PST) MIME-Version: 1.0 References: <20210106200713.31840-1-alobakin@pm.me> <20210106200801.31993-1-alobakin@pm.me> <20210106200801.31993-3-alobakin@pm.me> In-Reply-To: <20210106200801.31993-3-alobakin@pm.me> From: =?UTF-8?B?RsSBbmctcnXDrCBTw7JuZw==?= Date: Wed, 6 Jan 2021 12:21:53 -0800 Message-ID: Subject: Re: [PATCH v2 mips-next 3/4] MIPS: vmlinux.lds.S: catch bad .got, .plt and .rel.dyn at link time To: Alexander Lobakin Cc: Thomas Bogendoerfer , Nathan Chancellor , Kees Cook , Jiaxun Yang , Alex Smith , Ralf Baechle , Markos Chandras , linux-mips , "# 3.4.x" , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 6, 2021 at 12:08 PM Alexander Lobakin wrote: > > 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!") (INFO) drops the SHF_ALLOC flag from the output section (It does not mean "informational"). INFO is not need here. The diff from 815d680771ae09080d2da83dac2647c08cdf99ce "x86/build: Enforce an empty .got.plt section" is not needed. > + .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!") > } x86 has both .rel.dyn and .rela.dyn because i386 psABI uses REL while x86-64 psABI uses RELA, but mips does not need .rela.dyn > -- > 2.30.0 > >