diff mbox series

[uclibc-ng-devel,v1] m68k: fix SUPPORT_LD_DEBUG null pointer access

Message ID 20250220101102.653445-1-ps.report@gmx.net
State Superseded
Headers show
Series [uclibc-ng-devel,v1] m68k: fix SUPPORT_LD_DEBUG null pointer access | expand

Commit Message

Peter Seiderer Feb. 20, 2025, 10:11 a.m. UTC
Fix null pointer access in case SUPPORT_LD_DEBUG configuration option is
enabled.

Reported-by: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
Link: https://mailman.openadk.org/mailman3/hyperkitty/list/devel@uclibc-ng.org/thread/ODLJ53XJU5ZG3OLHVJMVWSNBYIFHFBAT/
Signed-off-by: Peter Seiderer <ps.report@gmx.net>
---
 ldso/ldso/m68k/elfinterp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jean-Michel Hautbois Feb. 20, 2025, 11:40 a.m. UTC | #1
Hi Peter,

Thanks for the patch !
Tested and it works fine:

On 20/02/2025 11:11, Peter Seiderer wrote:
> Fix null pointer access in case SUPPORT_LD_DEBUG configuration option is
> enabled.
> 
> Reported-by: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
> Link: https://mailman.openadk.org/mailman3/hyperkitty/list/devel@uclibc-ng.org/thread/ODLJ53XJU5ZG3OLHVJMVWSNBYIFHFBAT/
> Signed-off-by: Peter Seiderer <ps.report@gmx.net>

Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
Tested-by: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>

Thanks,
JM

> ---
>   ldso/ldso/m68k/elfinterp.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/ldso/ldso/m68k/elfinterp.c b/ldso/ldso/m68k/elfinterp.c
> index 25ea23067..1536bd5b2 100644
> --- a/ldso/ldso/m68k/elfinterp.c
> +++ b/ldso/ldso/m68k/elfinterp.c
> @@ -193,7 +193,7 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
>   #endif
>   
>   #if defined (__SUPPORT_LD_DEBUG__)
> -	old_val = *reloc_addr;
> +	old_val = reloc_addr ? *reloc_addr : 0;
>   #endif
>   
>   	switch (reloc_type) {
Peter Seiderer Feb. 20, 2025, 12:33 p.m. UTC | #2
Hello JM,

On Thu, 20 Feb 2025 12:40:53 +0100, Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org> wrote:

> Hi Peter,
>
> Thanks for the patch !
> Tested and it works fine:
>
> On 20/02/2025 11:11, Peter Seiderer wrote:
> > Fix null pointer access in case SUPPORT_LD_DEBUG configuration option is
> > enabled.
> >
> > Reported-by: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
> > Link: https://mailman.openadk.org/mailman3/hyperkitty/list/devel@uclibc-ng.org/thread/ODLJ53XJU5ZG3OLHVJMVWSNBYIFHFBAT/
> > Signed-off-by: Peter Seiderer <ps.report@gmx.net>
>
> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
> Tested-by: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>

Thanks for the quick (and positive) feedback, just sent out a
v2 of the patch as I spotted the same old_val/reloc_addr usage pattern
in _dl_do_lazy_reloc() and fixed that too...

Regards,
Peter

>
> Thanks,
> JM
>
> > ---
> >   ldso/ldso/m68k/elfinterp.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/ldso/ldso/m68k/elfinterp.c b/ldso/ldso/m68k/elfinterp.c
> > index 25ea23067..1536bd5b2 100644
> > --- a/ldso/ldso/m68k/elfinterp.c
> > +++ b/ldso/ldso/m68k/elfinterp.c
> > @@ -193,7 +193,7 @@ _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
> >   #endif
> >
> >   #if defined (__SUPPORT_LD_DEBUG__)
> > -	old_val = *reloc_addr;
> > +	old_val = reloc_addr ? *reloc_addr : 0;
> >   #endif
> >
> >   	switch (reloc_type) {
>
diff mbox series

Patch

diff --git a/ldso/ldso/m68k/elfinterp.c b/ldso/ldso/m68k/elfinterp.c
index 25ea23067..1536bd5b2 100644
--- a/ldso/ldso/m68k/elfinterp.c
+++ b/ldso/ldso/m68k/elfinterp.c
@@ -193,7 +193,7 @@  _dl_do_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
 #endif
 
 #if defined (__SUPPORT_LD_DEBUG__)
-	old_val = *reloc_addr;
+	old_val = reloc_addr ? *reloc_addr : 0;
 #endif
 
 	switch (reloc_type) {