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: <CAKwvOdkTW_uYqpEUODzL7Qyavo2LeOGVb6Mg3Lofdu12mjN1rA@mail.gmail.com>
Date:   Mon, 22 May 2023 11:31:35 -0700
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Masahiro Yamada <masahiroy@...nel.org>
Cc:     linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org,
        Nathan Chancellor <nathan@...nel.org>,
        Nicolas Schier <nicolas@...sle.eu>
Subject: Re: [PATCH v6 07/20] modpost: replace r->r_offset, r->r_addend with
 faddr, taddr

On Sun, May 21, 2023 at 9:05 AM Masahiro Yamada <masahiroy@...nel.org> wrote:
>
> r_offset/r_addend holds the offset address from/to which a symbol is
> referenced. It is unclear unless you are familiar with ELF.
>
> Rename them to faddr, taddr, respectively. The prefix 'f' means 'from',
> 't' means 'to'.
>
> Signed-off-by: Masahiro Yamada <masahiroy@...nel.org>


Do you care to rewrap the parameter lists?
```
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 4da96746a03b..8a787521963d 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1115,8 +1115,8 @@ static bool is_executable_section(struct
elf_info *elf, unsigned int secndx)

 static void default_mismatch_handler(const char *modname, struct elf_info *elf,
                                     const struct sectioncheck* const mismatch,
-                                    Elf_Sym *tsym,
-                                    unsigned int fsecndx, const char
*fromsec, Elf_Addr faddr,
+                                    Elf_Sym *tsym, unsigned int fsecndx,
+                                    const char *fromsec, Elf_Addr faddr,
                                     const char *tosec, Elf_Addr taddr)
 {
        Elf_Sym *from;
@@ -1217,9 +1217,9 @@ static void check_export_symbol(struct module
*mod, struct elf_info *elf,
 }

 static void check_section_mismatch(struct module *mod, struct elf_info *elf,
-                                  Elf_Sym *sym,
-                                  unsigned int fsecndx, const char *fromsec,
-                                  Elf_Addr faddr, Elf_Addr taddr)
+                                  Elf_Sym *sym, unsigned int fsecndx,
+                                  const char *fromsec, Elf_Addr faddr,
+                                  Elf_Addr taddr)
 {
        const char *tosec = sec_name(elf, get_secindex(elf, sym));
        const struct sectioncheck *mismatch;
```
Either way:
Reviewed-by: Nick Desaulniers <ndesaulniers@...gle.com>


> ---
>
>  scripts/mod/modpost.c | 34 +++++++++++++++++++---------------
>  1 file changed, 19 insertions(+), 15 deletions(-)
>
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index 7848bacd4b42..f364738a236e 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -1166,18 +1166,18 @@ static bool is_executable_section(struct elf_info *elf, unsigned int secndx)
>
>  static void default_mismatch_handler(const char *modname, struct elf_info *elf,
>                                      const struct sectioncheck* const mismatch,
> -                                    Elf_Rela *r, Elf_Sym *tsym,
> -                                    unsigned int fsecndx, const char *fromsec,
> -                                    const char *tosec)
> +                                    Elf_Sym *tsym,
> +                                    unsigned int fsecndx, const char *fromsec, Elf_Addr faddr,
> +                                    const char *tosec, Elf_Addr taddr)
>  {
>         Elf_Sym *from;
>         const char *tosym;
>         const char *fromsym;
>
> -       from = find_fromsym(elf, r->r_offset, fsecndx);
> +       from = find_fromsym(elf, faddr, fsecndx);
>         fromsym = sym_name(elf, from);
>
> -       tsym = find_tosym(elf, r->r_addend, tsym);
> +       tsym = find_tosym(elf, taddr, tsym);
>         tosym = sym_name(elf, tsym);
>
>         /* check whitelist - we may ignore it */
> @@ -1204,7 +1204,7 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
>                 break;
>         case EXTABLE_TO_NON_TEXT:
>                 warn("%s(%s+0x%lx): Section mismatch in reference to the %s:%s\n",
> -                    modname, fromsec, (long)r->r_offset, tosec, tosym);
> +                    modname, fromsec, (long)faddr, tosec, tosym);
>
>                 if (match(tosec, mismatch->bad_tosec))
>                         fatal("The relocation at %s+0x%lx references\n"
> @@ -1212,7 +1212,7 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
>                               "Something is seriously wrong and should be fixed.\n"
>                               "You might get more information about where this is\n"
>                               "coming from by using scripts/check_extable.sh %s\n",
> -                             fromsec, (long)r->r_offset, tosec, modname);
> +                             fromsec, (long)faddr, tosec, modname);
>                 else if (is_executable_section(elf, get_secindex(elf, tsym)))
>                         warn("The relocation at %s+0x%lx references\n"
>                              "section \"%s\" which is not in the list of\n"
> @@ -1221,17 +1221,18 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
>                              "list of authorized sections to jump to on fault.\n"
>                              "This can be achieved by adding \"%s\" to\n"
>                              "OTHER_TEXT_SECTIONS in scripts/mod/modpost.c.\n",
> -                            fromsec, (long)r->r_offset, tosec, tosec, tosec);
> +                            fromsec, (long)faddr, tosec, tosec, tosec);
>                 else
>                         error("%s+0x%lx references non-executable section '%s'\n",
> -                             fromsec, (long)r->r_offset, tosec);
> +                             fromsec, (long)faddr, tosec);
>                 break;
>         }
>  }
>
>  static void check_section_mismatch(const char *modname, struct elf_info *elf,
> -                                  Elf_Rela *r, Elf_Sym *sym,
> -                                  unsigned int fsecndx, const char *fromsec)
> +                                  Elf_Sym *sym,
> +                                  unsigned int fsecndx, const char *fromsec,
> +                                  Elf_Addr faddr, Elf_Addr taddr)
>  {
>         const char *tosec = sec_name(elf, get_secindex(elf, sym));
>         const struct sectioncheck *mismatch = section_mismatch(fromsec, tosec);
> @@ -1239,8 +1240,9 @@ static void check_section_mismatch(const char *modname, struct elf_info *elf,
>         if (!mismatch)
>                 return;
>
> -       default_mismatch_handler(modname, elf, mismatch, r, sym, fsecndx, fromsec,
> -                                tosec);
> +       default_mismatch_handler(modname, elf, mismatch, sym,
> +                                fsecndx, fromsec, faddr,
> +                                tosec, taddr);
>  }
>
>  static unsigned int *reloc_location(struct elf_info *elf,
> @@ -1406,7 +1408,8 @@ static void section_rela(const char *modname, struct elf_info *elf,
>                 /* Skip special sections */
>                 if (is_shndx_special(sym->st_shndx))
>                         continue;
> -               check_section_mismatch(modname, elf, &r, sym, fsecndx, fromsec);
> +               check_section_mismatch(modname, elf, sym,
> +                                      fsecndx, fromsec, r.r_offset, r.r_addend);
>         }
>  }
>
> @@ -1464,7 +1467,8 @@ static void section_rel(const char *modname, struct elf_info *elf,
>                 /* Skip special sections */
>                 if (is_shndx_special(sym->st_shndx))
>                         continue;
> -               check_section_mismatch(modname, elf, &r, sym, fsecndx, fromsec);
> +               check_section_mismatch(modname, elf, sym,
> +                                      fsecndx, fromsec, r.r_offset, r.r_addend);
>         }
>  }
>
> --
> 2.39.2
>


-- 
Thanks,
~Nick Desaulniers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ