From: Alexandre Ghiti <alex@ghiti.fr>
To: Samuel Holland <samuel.holland@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
linux-riscv@lists.infradead.org
Cc: "Andrew Jones" <ajones@ventanamicro.com>,
"Pinkesh Vaghela" <pinkesh.vaghela@einfochips.com>,
"Pritesh Patel" <pritesh.patel@einfochips.com>,
"Darshan Prajapati" <darshan.prajapati@einfochips.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Amma Lee" <lixiaoyun@binary-semi.com>,
"Charlie Jenkins" <charlie@rivosinc.com>,
"Clément Léger" <cleger@rivosinc.com>,
"Jinjie Ruan" <ruanjinjie@huawei.com>,
"Luis Chamberlain" <mcgrof@kernel.org>,
"Maxim Kochetkov" <fido_max@inbox.ru>,
"Mike Rapoport (IBM)" <rppt@kernel.org>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/3] riscv: module: Fix out-of-bounds relocation access
Date: Fri, 11 Apr 2025 13:21:35 +0200 [thread overview]
Message-ID: <fb65fc45-b1f1-47ef-b700-e90c6ef84957@ghiti.fr> (raw)
In-Reply-To: <20250409171526.862481-1-samuel.holland@sifive.com>
Hi Samuel,
On 09/04/2025 19:14, Samuel Holland wrote:
> The current code allows rel[j] to access one element past the end of the
> relocation section. Simplify to num_relocations which is equivalent to
> the existing size expression.
>
> Fixes: 080c4324fa5e ("riscv: optimize ELF relocation function in riscv")
> Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
> ---
>
> Changes in v2:
> - New patch for v2
>
> arch/riscv/kernel/module.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c
> index 47d0ebeec93c..060f576cc988 100644
> --- a/arch/riscv/kernel/module.c
> +++ b/arch/riscv/kernel/module.c
> @@ -859,7 +859,7 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
> }
>
> j++;
> - if (j > sechdrs[relsec].sh_size / sizeof(*rel))
> + if (j == num_relocations)
> j = 0;
>
> } while (j_idx != j);
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Thanks,
Alex
next prev parent reply other threads:[~2025-04-11 11:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-09 17:14 Samuel Holland
2025-04-09 17:14 ` [PATCH v2 2/3] riscv: module: Allocate PLT entries for R_RISCV_PLT32 Samuel Holland
2025-04-09 18:53 ` Andrew Jones
2025-04-09 17:14 ` [PATCH v2 3/3] riscv: module: Optimize PLT/GOT entry counting Samuel Holland
2025-04-09 19:07 ` Andrew Jones
2025-04-09 19:18 ` Samuel Holland
2025-04-09 19:24 ` Andrew Jones
2025-04-09 19:11 ` [PATCH v2 1/3] riscv: module: Fix out-of-bounds relocation access Maxim Kochetkov
2025-04-11 11:21 ` Alexandre Ghiti [this message]
2025-04-16 18:42 ` patchwork-bot+linux-riscv
2025-06-02 22:12 ` patchwork-bot+linux-riscv
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=fb65fc45-b1f1-47ef-b700-e90c6ef84957@ghiti.fr \
--to=alex@ghiti.fr \
--cc=ajones@ventanamicro.com \
--cc=aou@eecs.berkeley.edu \
--cc=charlie@rivosinc.com \
--cc=cleger@rivosinc.com \
--cc=darshan.prajapati@einfochips.com \
--cc=fido_max@inbox.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=lixiaoyun@binary-semi.com \
--cc=mcgrof@kernel.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=pinkesh.vaghela@einfochips.com \
--cc=pritesh.patel@einfochips.com \
--cc=rppt@kernel.org \
--cc=ruanjinjie@huawei.com \
--cc=samuel.holland@sifive.com \
/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
all inboxes | Powered by JetHome®