Skip to content

Commit 74a2810

Browse files
MQ-mengqingtsbogend
authored andcommitted
MIPS: KASLR: Correct valid bits in apply_r_mips_26_rel()
Apply_r_mips_26_rel() relocates instructions like j, jal and etc. These instructions consist of 6bits function field and 26bits address field. The value of target_addr as follows, ================================================================= | high 4bits | low 28bits | ================================================================= |the high 4bits of this PC | the low 26bits of instructions << 2| ================================================================= Thus, loc_orig and log_new both need high 4bits rather than high 6bits. Signed-off-by: Jinyang He <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent 91c7a7e commit 74a2810

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/mips/kernel/relocate.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static int __init apply_r_mips_26_rel(u32 *loc_orig, u32 *loc_new, long offset)
9595

9696
/* Original target address */
9797
target_addr <<= 2;
98-
target_addr += (unsigned long)loc_orig & ~0x03ffffff;
98+
target_addr += (unsigned long)loc_orig & 0xf0000000;
9999

100100
/* Get the new target address */
101101
target_addr += offset;
@@ -105,7 +105,7 @@ static int __init apply_r_mips_26_rel(u32 *loc_orig, u32 *loc_new, long offset)
105105
return -ENOEXEC;
106106
}
107107

108-
target_addr -= (unsigned long)loc_new & ~0x03ffffff;
108+
target_addr -= (unsigned long)loc_new & 0xf0000000;
109109
target_addr >>= 2;
110110

111111
*loc_new = (*loc_new & ~0x03ffffff) | (target_addr & 0x03ffffff);

0 commit comments

Comments
 (0)