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: <CAK7LNAT7ni-nOmhyjPByn=a40a-_D2sgkhvNFpqgHQsPDMm7Tg@mail.gmail.com>
Date:   Wed, 3 Aug 2022 19:05:23 +0900
From:   Masahiro Yamada <masahiroy@...nel.org>
To:     Nick Desaulniers <ndesaulniers@...gle.com>
Cc:     Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>,
        Michal Marek <michal.lkml@...kovi.net>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/3] modpost: add array range check to sec_name()

On Wed, Aug 3, 2022 at 2:55 AM Nick Desaulniers <ndesaulniers@...gle.com> wrote:
>
> On Sat, Jul 30, 2022 at 10:37 AM Masahiro Yamada <masahiroy@...nel.org> wrote:
> >
> > The section index is always positive, so the argunent, secindex, should
> > be unsigned.
> >
> > Also, inserted the array range check.
> >
> > If sym->st_shndx is a special section index (between SHN_LORESERVE and
> > SHN_HIRESERVE), there is no corresponding section header.
> >
> > For example, if a symbol specifies an absolute value, sym->st_shndx is
> > SHN_ABS (=0xfff1).
> >
> > The current users do not cause the out-of-range access of
> > info->sechddrs[], but it is better to avoid such a pitfall.
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@...nel.org>
>
> I don't mind adding this check; though if it's anomalous I think we
> could also just print to stderr and abort.


If  sec_name() has a failure path,
I need to add another check before calling sec_name().


I want to get a return value that can be safely passed
to strcmp(), etc.


For example,

   strcmp(!sec_name(elf, secindex),  "some_pattern");


Returning "" for special sections
will work nicely without additional check code.



I am changing the code with a bigger picture in my mind,
although that may not be so clear if you look at this patch only.



> I would prefer Elf_Sym over unsigned int though.  WDYT?
>

In /usr/include/elf.h, Elf{32,64}_Sym are structures.
How to use it instead of unsigned int?


typedef struct
{
  Elf32_Word    st_name;                /* Symbol name (string tbl index) */
  Elf32_Addr    st_value;               /* Symbol value */
  Elf32_Word    st_size;                /* Symbol size */
  unsigned char st_info;                /* Symbol type and binding */
  unsigned char st_other;               /* Symbol visibility */
  Elf32_Section st_shndx;               /* Section index */
} Elf32_Sym;

typedef struct
{
  Elf64_Word    st_name;                /* Symbol name (string tbl index) */
  unsigned char st_info;                /* Symbol type and binding */
  unsigned char st_other;               /* Symbol visibility */
  Elf64_Section st_shndx;               /* Section index */
  Elf64_Addr    st_value;               /* Symbol value */
  Elf64_Xword   st_size;                /* Symbol size */
} Elf64_Sym;




Best Regards
Masahiro Yamada

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ