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: <YFjLqKV9GxGSXcAr@hirez.programming.kicks-ass.net>
Date:   Mon, 22 Mar 2021 17:54:00 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     Jessica Yu <jeyu@...nel.org>
Cc:     Steven Rostedt <rostedt@...dmis.org>,
        Josh Poimboeuf <jpoimboe@...hat.com>, x86@...nel.org,
        jbaron@...mai.com, ardb@...nel.org, linux-kernel@...r.kernel.org,
        sumit.garg@...aro.org, oliver.sang@...el.com, jarkko@...nel.org
Subject: Re: [PATCH 3/3] static_call: Fix static_call_update() sanity check

On Mon, Mar 22, 2021 at 03:50:14PM +0100, Jessica Yu wrote:

> It should be doable. If you want the exit sections to be treated the same as
> module init, the following patch should stuff any exit sections into the module
> init "region" (completely untested). Hence it should be freed together with the
> init sections and it would identify as init through within_module_init(). Let
> me know if this works for you.

That does indeed seem to DTRT from a quick scan of module.c. Very nice
tidy patch. I was afraid it'd be much worse.

Assuming it actually works; for your Changelog:

"Dynamic code patching (alternatives, jump_label and static_call) can
have sites in __exit code, even it __exit is never executed. Therefore
__exit must be present at runtime, at least for as long as __init code
is.

Additionally, for jump_label and static_call, the __exit sites must also
identify as within_module_init(), such that the infrastructure is aware
to never touch them after module init -- alternatives are only ran once
at init and hence don't have this particular constraint.

By making __exit identify as __init for UNLOAD_MODULE, the above is
satisfied."

Thanks!

> ---
> 
> diff --git a/kernel/module.c b/kernel/module.c
> index 30479355ab85..1c3396a9dd8b 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -2802,7 +2802,11 @@ void * __weak module_alloc(unsigned long size)
> 
>  bool __weak module_init_section(const char *name)
>  {
> -       return strstarts(name, ".init");
> +#ifndef CONFIG_UNLOAD_MODULE
> +       return strstarts(name, ".init") || module_exit_section(name);
> +#else
> +       return strstarts(name, ".init")
> +#endif
>  }
> 
>  bool __weak module_exit_section(const char *name)
> @@ -3116,11 +3120,6 @@ static int rewrite_section_headers(struct load_info *info, int flags)
>                  */
>                 shdr->sh_addr = (size_t)info->hdr + shdr->sh_offset;
> 
> -#ifndef CONFIG_MODULE_UNLOAD
> -               /* Don't load .exit sections */
> -               if (module_exit_section(info->secstrings+shdr->sh_name))
> -                       shdr->sh_flags &= ~(unsigned long)SHF_ALLOC;
> -#endif
>         }
> 
>         /* Track but don't keep modinfo and version sections. */
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ