lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAF1bQ=TUYoc3kUnBOtO4BWfuDLb5_YdxduVGsMfsyP7jLWmH5w@mail.gmail.com>
Date: Wed, 13 Nov 2024 10:13:10 -0800
From: Rong Xu <xur@...gle.com>
To: "Maciej W. Rozycki" <macro@...am.me.uk>
Cc: Thomas Bogendoerfer <tsbogend@...ha.franken.de>, Masahiro Yamada <masahiroy@...nel.org>, 
	Nick Desaulniers <ndesaulniers@...gle.com>, Klara Modin <klarasmodin@...il.com>, 
	linux-mips@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] MIPS: move _stext definition to vmlinux.lds.S

"

On Wed, Nov 13, 2024 at 7:55 AM Maciej W. Rozycki <macro@...am.me.uk> wrote:
>
> On Tue, 12 Nov 2024, Rong Xu wrote:
>
> > The _stext symbol is intended to reference the start of the text section.
> > However, it currently relies on a fragile link order because the existing
> > EXPORT(_stext) resides within the .text section, which is not guaranteed
> > to be placed first.
>
>  Umm, arch/mips/kernel/head.S does mean to be linked first.  We rely on it
> for environments where there's no entry point is available and execution
> starts from the beginning of the image.  See the comment right below your
> change.
>
When you said "arch/mips/kernel/head.S does mean to be linked first", is it
a hard requirement in mips? This patch only moves _stext but leaves other
symbols from heads.S for TEXT_TEXT macro to order. For example,
__kernel_entry is placed in the middle of the text segment.

If we want head.S to be linked first, I can change the patch to place
all symbols from head.S before TEXT_TEXT.
This way, we can also resolve your concerns about moving _stext byond
the exception handlers.

I tried that method, and the symbol order is like the following:
0100000 T _text
80100400 T __kernel_entry
80100400 T _stext
80100410 T file_ra_state_init
80100450 T readahead_expand
80100710 t read_pages
80100a04 T page_cache_ra_unbounded
80100c10 t do_page_cache_ra
80100c9c T force_page_cache_ra
80100d50 T page_cache_ra_order
80100d8c T page_cache_sync_ra
80100ff4 T page_cache_async_ra
801011b8 T ksys_readahead
801012cc T __se_sys_readahead
801012cc T sys_readahead
801012e0 T __split_text_end
801012e0 T __split_text_start
801012e0 t __sync
...
Note that the reserve space for exceptions is before _stext

> > Move the _stext definition to the linker script to enforce an explicit
> > ordering.
>
>  So if you say that the link order is fragile (which it may well be), then
> that problem has to be fixed instead, likely with the linker script too,

I think what we meant was the way the current vmlinux.lds.S (linker
script) written
makes the symbol ordering fragile. This patch is to fix this.

> and then perhaps an ASSERT placed there to verify that it has worked and
> `_stext' refers to the beginning, taking into account what follows too.
>
>  Also note that `_stext' currently points beyond the space reserved for
> exception handlers.  Have you analysed what the consequences would be if
> it was moved ahead of it, which your change does AFAICT?

I did not analyze this. I think it's fine. From section boundaries guideline in
include/asm-generic/sections.h
It seems ok to me that exception handlers are included in [_stext, _etext].
But I admit that I'm not an expert here.
We can use the method I mentioned above to keep current behavior.

>   Maciej

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ