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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdkC3RYjOPx-DS0fSCHsts1YGzotBOs4fTKTQk7WZWfBgg@mail.gmail.com>
Date:   Tue, 5 Apr 2022 09:26:17 -0700
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Masahiro Yamada <masahiroy@...nel.org>
Cc:     linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org,
        Michal Marek <michal.lkml@...kovi.net>
Subject: Re: [PATCH v2 06/10] modpost: remove annoying namespace_from_kstrtabns()

On Tue, Apr 5, 2022 at 4:34 AM Masahiro Yamada <masahiroy@...nel.org> wrote:
>
> There are two call sites for sym_update_namespace().
>
> When the symbol has no namespace, s->namespace is set to NULL,
> but the conversion from "" to NULL is done in two different places.
>
> [1] read_symbols()
>
>   This gets the namespace from __kstrtabns_<symbol>. If the symbol has
>   no namespace, sym_get_data(info, sym) returns the empty string "".
>   namespace_from_kstrtabns() converts it to NULL before it is passed to
>   sym_update_namespace().
>
> [2] read_dump()
>
>   This gets the namespace from the dump file, *.symvers. If the symbol
>   has no namespace, the 'namespace' is the empty string "", which is
>   directly passed into sym_update_namespace(). The conversion from
>   "" to NULL is done in sym_update_namespace().
>
> namespace_from_kstrtabns() exists only for creating this inconsistency.
>
> By removing it, sym_update_namespace() is consistently passed with ""
> when the symbol has no namespace.
>
> Signed-off-by: Masahiro Yamada <masahiroy@...nel.org>

Thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@...gle.com>

> ---
>
> Changes in v2:
>   - new
>
>  scripts/mod/modpost.c | 14 ++------------
>  1 file changed, 2 insertions(+), 12 deletions(-)
>
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index 2a202764ff48..522d5249d196 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -369,13 +369,6 @@ static enum export export_from_secname(struct elf_info *elf, unsigned int sec)
>                 return export_unknown;
>  }
>
> -static const char *namespace_from_kstrtabns(const struct elf_info *info,
> -                                           const Elf_Sym *sym)
> -{
> -       const char *value = sym_get_data(info, sym);
> -       return value[0] ? value : NULL;
> -}
> -
>  static void sym_update_namespace(const char *symname, const char *namespace)
>  {
>         struct symbol *s = find_symbol(symname);
> @@ -391,8 +384,7 @@ static void sym_update_namespace(const char *symname, const char *namespace)
>         }
>
>         free(s->namespace);
> -       s->namespace =
> -               namespace && namespace[0] ? NOFAIL(strdup(namespace)) : NULL;
> +       s->namespace = namespace[0] ? NOFAIL(strdup(namespace)) : NULL;
>  }
>
>  /**
> @@ -2049,9 +2041,7 @@ static void read_symbols(const char *modname)
>                 /* Apply symbol namespaces from __kstrtabns_<symbol> entries. */
>                 if (strstarts(symname, "__kstrtabns_"))
>                         sym_update_namespace(symname + strlen("__kstrtabns_"),
> -                                            namespace_from_kstrtabns(&info,
> -                                                                     sym));
> -
> +                                            sym_get_data(&info, sym));
>                 if (strstarts(symname, "__crc_"))
>                         handle_modversion(mod, &info, sym,
>                                           symname + strlen("__crc_"));
> --
> 2.32.0
>


-- 
Thanks,
~Nick Desaulniers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ