diff mbox series

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

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

Commit Message

Peter Seiderer Feb. 20, 2025, 12:18 p.m. UTC
Fix null pointer access in case SUPPORT_LD_DEBUG configuration option is
enabled (hit in _dl_do_reloc, but fix same old_val/reloc_addr usage pattern
in _dl_do_lazy_reloc too).

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>
---
Changes v1 -> v2:
  - fix same old_val/reloc_addr usage pattern in _dl_do_lazy_reloc too
  - reword commit message
---
 ldso/ldso/m68k/elfinterp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jean-Michel Hautbois Feb. 20, 2025, 1:03 p.m. UTC | #1
Hi Peter,

On 20/02/2025 13:18, Peter Seiderer wrote:
> Fix null pointer access in case SUPPORT_LD_DEBUG configuration option is
> enabled (hit in _dl_do_reloc, but fix same old_val/reloc_addr usage pattern
> in _dl_do_lazy_reloc too).
> 
> 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>
> ---
> Changes v1 -> v2:
>    - fix same old_val/reloc_addr usage pattern in _dl_do_lazy_reloc too
>    - reword commit message

You can take my reviewed/tested-by, it works fine too :-).

Thanks !
JM

> ---
>   ldso/ldso/m68k/elfinterp.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/ldso/ldso/m68k/elfinterp.c b/ldso/ldso/m68k/elfinterp.c
> index 25ea23067..e7fa117da 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) {
> @@ -292,7 +292,7 @@ _dl_do_lazy_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
>   	reloc_type = ELF_R_TYPE(rpnt->r_info);
>   
>   #if defined (__SUPPORT_LD_DEBUG__)
> -	old_val = *reloc_addr;
> +	old_val = reloc_addr ? *reloc_addr : 0;
>   #endif
>   
>   	switch (reloc_type) {
Waldemar Brodkorb Feb. 22, 2025, 8 a.m. UTC | #2
Hi Peter,

thanks you very much. Applied and pushed.

best regards
 Waldemar

Peter Seiderer wrote,

> Fix null pointer access in case SUPPORT_LD_DEBUG configuration option is
> enabled (hit in _dl_do_reloc, but fix same old_val/reloc_addr usage pattern
> in _dl_do_lazy_reloc too).
> 
> 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>
> ---
> Changes v1 -> v2:
>   - fix same old_val/reloc_addr usage pattern in _dl_do_lazy_reloc too
>   - reword commit message
> ---
>  ldso/ldso/m68k/elfinterp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/ldso/ldso/m68k/elfinterp.c b/ldso/ldso/m68k/elfinterp.c
> index 25ea23067..e7fa117da 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) {
> @@ -292,7 +292,7 @@ _dl_do_lazy_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
>  	reloc_type = ELF_R_TYPE(rpnt->r_info);
>  
>  #if defined (__SUPPORT_LD_DEBUG__)
> -	old_val = *reloc_addr;
> +	old_val = reloc_addr ? *reloc_addr : 0;
>  #endif
>  
>  	switch (reloc_type) {
> -- 
> 2.48.1
>
diff mbox series

Patch

diff --git a/ldso/ldso/m68k/elfinterp.c b/ldso/ldso/m68k/elfinterp.c
index 25ea23067..e7fa117da 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) {
@@ -292,7 +292,7 @@  _dl_do_lazy_reloc(struct elf_resolve *tpnt, struct r_scope_elem *scope,
 	reloc_type = ELF_R_TYPE(rpnt->r_info);
 
 #if defined (__SUPPORT_LD_DEBUG__)
-	old_val = *reloc_addr;
+	old_val = reloc_addr ? *reloc_addr : 0;
 #endif
 
 	switch (reloc_type) {