Skip to contentSkip to conversation

ARM: module: Drop 'rel->r_offset < 0' always false statement

PATCH Superseded Austin Kim 2 participants 3 messages Sep 11, 2019 Arm (32-bit)

lore
Share & tools
lore

Austin Kim

author
#0 lore raw

PATCH 1/1 ARM: module: Drop 'rel->r_offset < 0' always false statement

Since rel->r_offset is declared as Elf32_Addr,
this value is always non-negative.

typedef struct elf32_rel {
	  Elf32_Addr	r_offset;
	    Elf32_Word	r_info;
} Elf32_Rel;

typedef __u32 Elf32_Addr;
typedef unsigned int __u32;

Drop 'rel->r_offset < 0' statement which is always false.

---
 arch/arm/kernel/module.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/kernel/module.c +1 -1
index deef17f..0921ce7 100644
@@ -92,7 +92,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
 		sym = ((Elf32_Sym *)symsec->sh_addr) + offset;
 		symname = strtab + sym->st_name;
 
-		if (rel->r_offset < 0 || rel->r_offset > dstsec->sh_size - sizeof(u32)) {
+		if (rel->r_offset > dstsec->sh_size - sizeof(u32)) {
 			pr_err("%s: section %u reloc %u sym '%s': out of bounds relocation, offset %d size %u\n",
 			       module->name, relindex, i, symname,
 			       rel->r_offset, dstsec->sh_size);
Signature · 1 line
2.6.2
#1 lore raw
Quoted 22 lines · Austin Kim

Since rel->r_offset is declared as Elf32_Addr,
this value is always non-negative.

typedef struct elf32_rel {
	  Elf32_Addr	r_offset;
	    Elf32_Word	r_info;
} Elf32_Rel;

typedef __u32 Elf32_Addr;
typedef unsigned int __u32;

Drop 'rel->r_offset < 0' statement which is always false.

---
 arch/arm/kernel/module.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/kernel/module.c +0 -0
index deef17f..0921ce7 100644

arch/arm/kernel/module.c apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex, · line 96

Quoted 6 lines
arch/arm/kernel/module.c +1 -1
@@ -92,7 +92,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
 		sym = ((Elf32_Sym *)symsec->sh_addr) + offset;
 		symname = strtab + sym->st_name;
 
-		if (rel->r_offset < 0 || rel->r_offset > dstsec->sh_size - sizeof(u32)) {
+		if (rel->r_offset > dstsec->sh_size - sizeof(u32)) {
 			pr_err("%s: section %u reloc %u sym '%s': out of bounds relocation, offset %d size %u\n",

Also change %d to %u here.

Quoted 6 lines
arch/arm/kernel/module.c +0 -0
 			       module->name, relindex, i, symname,
 			       rel->r_offset, dstsec->sh_size);
Signature · 1 line
2.6.2
Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up
author
#2 lore raw

2019년 9월 11일 (수) 오후 6:40, Russell King - ARM Linux admin <[email protected]>님이 작성:

Quoted 27 lines · Austin Kim
Quoted 25 lines

Since rel->r_offset is declared as Elf32_Addr,
this value is always non-negative.

typedef struct elf32_rel {
        Elf32_Addr    r_offset;
          Elf32_Word  r_info;
} Elf32_Rel;

typedef __u32 Elf32_Addr;
typedef unsigned int __u32;

Drop 'rel->r_offset < 0' statement which is always false.

---
 arch/arm/kernel/module.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/kernel/module.c +0 -0
index deef17f..0921ce7 100644
@@ -92,7 +92,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
              sym = ((Elf32_Sym *)symsec->sh_addr) + offset;
              symname = strtab + sym->st_name;
 
Quoted 5 lines

arch/arm/kernel/module.c apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex, · line 96

Quoted 3 lines
arch/arm/kernel/module.c +1 -1
-             if (rel->r_offset < 0 || rel->r_offset > dstsec->sh_size - sizeof(u32)) {
+             if (rel->r_offset > dstsec->sh_size - sizeof(u32)) {
                      pr_err("%s: section %u reloc %u sym '%s': out of bounds relocation, offset %d size %u\n",

Also change %d to %u here.

Let me resend the patch with the change(%d to %u).

Thanks,
Austin Kim

Quoted 12 lines
Quoted 7 lines
arch/arm/kernel/module.c +0 -1
                             module->name, relindex, i, symname,
                             rel->r_offset, dstsec->sh_size);
--

2.6.2

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up