public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: Quentin Casasnovas <quentin.casasnovas@oracle.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: quentin.casasnovas@oracle.com,
	Masahiro Yamada <masahiroy@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Nicolas Schier <nicolas@fjasle.eu>,
	linux-kbuild@vger.kernel.org
Subject: Re: [bug report] modpost: handle relocations mismatch in __ex_table.
Date: Mon, 12 Jun 2023 11:37:00 +0200	[thread overview]
Message-ID: <ZIbnPPQbrtmmRiQO@chrystal> (raw)
In-Reply-To: <ZH7uxFaLhjul0jp1@moroto>

[-- Attachment #1: Type: text/plain, Size: 1085 bytes --]

On Tue, Jun 06, 2023 at 11:31:00AM +0300, Dan Carpenter wrote:
> [ Ancient code warning. - dan ]
> 
> Hello Quentin Casasnovas,
> 
> The patch 52dc0595d540: "modpost: handle relocations mismatch in
> __ex_table." from Apr 13, 2015, leads to the following Smatch static
> checker warning:
> 
> 	./scripts/mod/modpost.c:1154 is_executable_section()
> 	warn: array off by one? 'elf->sechdrs[secndx]'
> 
> ./scripts/mod/modpost.c
>     1149 static bool is_executable_section(struct elf_info *elf, unsigned int secndx)
>     1150 {
>     1151         if (secndx > elf->num_sections)
>                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
> I'm not positive, but I think this should be >=.
> 
>     1152                 return false;
>     1153 
> --> 1154         return (elf->sechdrs[secndx].sh_flags & SHF_EXECINSTR) != 0;
>                                       ^^^^^^
> out of bounds read.
> 

Oops, that is embarassing - thanks for catching that!

Have you already prepared a fix or shall I send it over?

Q


>     1155 }
> 
> regards,
> dan carpenter

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2023-06-12  9:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-06  8:31 [bug report] modpost: handle relocations mismatch in __ex_table Dan Carpenter
2023-06-06  9:16 ` Masahiro Yamada
2023-06-12  9:37 ` Quentin Casasnovas [this message]
2023-06-12  9:51   ` Dan Carpenter
2023-06-12 10:22     ` Quentin Casasnovas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZIbnPPQbrtmmRiQO@chrystal \
    --to=quentin.casasnovas@oracle.com \
    --cc=dan.carpenter@linaro.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nicolas@fjasle.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox