From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-f66.google.com ([209.85.216.66]:40183 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726797AbgCVJTh (ORCPT ); Sun, 22 Mar 2020 05:19:37 -0400 Date: Sun, 22 Mar 2020 19:16:29 +1000 From: Nicholas Piggin Subject: Re: [PATCH 1/9] scripts/link-vmlinux.sh: Delay orphan handling warnings until final link References: <20200228002244.15240-1-keescook@chromium.org> <20200228002244.15240-2-keescook@chromium.org> <1584672297.mudnpz3ir9.astroid@bobo.none> <202003201121.8CBD96451B@keescook> In-Reply-To: <202003201121.8CBD96451B@keescook> MIME-Version: 1.0 Message-Id: <1584868418.o62lxee8k1.astroid@bobo.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sender: linux-kbuild-owner@vger.kernel.org List-ID: To: Kees Cook Cc: Arnd Bergmann , Borislav Petkov , Catalin Marinas , clang-built-linux@googlegroups.com, "H.J. Lu" , James Morse , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Russell King , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Rutland , Masahiro Yamada , Peter Collingbourne , Will Deacon , x86@kernel.org Kees Cook's on March 21, 2020 4:24 am: > On Fri, Mar 20, 2020 at 12:47:54PM +1000, Nicholas Piggin wrote: >> Kees Cook's on February 28, 2020 10:22 am: >> > Right now, powerpc adds "--orphan-handling=3Dwarn" to LD_FLAGS_vmlinux >> > to detect when there are unexpected sections getting added to the kern= el >> > image. There is no need to report these warnings more than once, so it >> > can be removed until the final link stage. >> >=20 >> > This helps pave the way for other architectures to enable this, with t= he >> > end goal of enabling this warning by default for vmlinux for all >> > architectures. >> >=20 >> > Signed-off-by: Kees Cook >> > --- >> > scripts/link-vmlinux.sh | 6 ++++++ >> > 1 file changed, 6 insertions(+) >> >=20 >> > diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh >> > index 1919c311c149..416968fea685 100755 >> > --- a/scripts/link-vmlinux.sh >> > +++ b/scripts/link-vmlinux.sh >> > @@ -255,6 +255,11 @@ info GEN modules.builtin >> > tr '\0' '\n' < modules.builtin.modinfo | sed -n 's/^[[:alnum:]:_]*\.f= ile=3D//p' | >> > tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$/.ko/' > modules.b= uiltin >> > =20 >> > + >> > +# Do not warn about orphan sections until the final link stage. >> > +saved_LDFLAGS_vmlinux=3D"${LDFLAGS_vmlinux}" >> > +LDFLAGS_vmlinux=3D"$(echo "${LDFLAGS_vmlinux}" | sed -E 's/ --orphan-= handling=3Dwarn( |$)/ /g')" >> > + >> > btf_vmlinux_bin_o=3D"" >> > if [ -n "${CONFIG_DEBUG_INFO_BTF}" ]; then >> > if gen_btf .tmp_vmlinux.btf .btf.vmlinux.bin.o ; then >> > @@ -306,6 +311,7 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then >> > fi >> > fi >> > =20 >> > +LDFLAGS_vmlinux=3D"${saved_LDFLAGS_vmlinux}" >> > vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o} >> > =20 >> > if [ -n "${CONFIG_BUILDTIME_TABLE_SORT}" ]; then >>=20 >> That's ugly. Why not just enable it for all archs? >=20 > It is ugly; I agree. >=20 > I can try to do this for all architectures, but I worry there are a > bunch I can't test. But I guess it would stand out. ;) It's only warn, so it doesn't break their builds (unless there's a=20 linker error on warn option I don't know about?). We had a powerpc bug=20 that would have been caught with it as well, so it's not a bad idea to get everyone using it. I would just do it. Doesn't take much to fix. Thanks, Nick =