diff options
Diffstat (limited to 'arch/arm64/kernel/module.c')
| -rw-r--r-- | arch/arm64/kernel/module.c | 18 | 
1 files changed, 15 insertions, 3 deletions
diff --git a/arch/arm64/kernel/module.c b/arch/arm64/kernel/module.c index f713e2fc4d75..f32359cffb01 100644 --- a/arch/arm64/kernel/module.c +++ b/arch/arm64/kernel/module.c  | |||
| @@ -56,7 +56,7 @@ void *module_alloc(unsigned long size) | |||
| 56 | * can simply omit this fallback in that case. | 56 | * can simply omit this fallback in that case. | 
| 57 | */ | 57 | */ | 
| 58 | p = __vmalloc_node_range(size, MODULE_ALIGN, module_alloc_base, | 58 | p = __vmalloc_node_range(size, MODULE_ALIGN, module_alloc_base, | 
| 59 | module_alloc_base + SZ_4G, GFP_KERNEL, | 59 | module_alloc_base + SZ_2G, GFP_KERNEL, | 
| 60 | PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE, | 60 | PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE, | 
| 61 | __builtin_return_address(0)); | 61 | __builtin_return_address(0)); | 
| 62 | 62 | ||
| @@ -96,15 +96,27 @@ static int reloc_data(enum aarch64_reloc_op op, void *place, u64 val, int len) | |||
| 96 | { | 96 | { | 
| 97 | s64 sval = do_reloc(op, place, val); | 97 | s64 sval = do_reloc(op, place, val); | 
| 98 | 98 | ||
| 99 | /* | ||
| 100 | * The ELF psABI for AArch64 documents the 16-bit and 32-bit place | ||
| 101 | * relative relocations as having a range of [-2^15, 2^16) or | ||
| 102 | * [-2^31, 2^32), respectively. However, in order to be able to detect | ||
| 103 | * overflows reliably, we have to choose whether we interpret such | ||
| 104 | * quantities as signed or as unsigned, and stick with it. | ||
| 105 | * The way we organize our address space requires a signed | ||
| 106 | * interpretation of 32-bit relative references, so let's use that | ||
| 107 | * for all R_AARCH64_PRELxx relocations. This means our upper | ||
| 108 | * bound for overflow detection should be Sxx_MAX rather than Uxx_MAX. | ||
| 109 | */ | ||
| 110 | |||
| 99 | switch (len) { | 111 | switch (len) { | 
| 100 | case 16: | 112 | case 16: | 
| 101 | *(s16 *)place = sval; | 113 | *(s16 *)place = sval; | 
| 102 | if (sval < S16_MIN || sval > U16_MAX) | 114 | if (sval < S16_MIN || sval > S16_MAX) | 
| 103 | return -ERANGE; | 115 | return -ERANGE; | 
| 104 | break; | 116 | break; | 
| 105 | case 32: | 117 | case 32: | 
| 106 | *(s32 *)place = sval; | 118 | *(s32 *)place = sval; | 
| 107 | if (sval < S32_MIN || sval > U32_MAX) | 119 | if (sval < S32_MIN || sval > S32_MAX) | 
| 108 | return -ERANGE; | 120 | return -ERANGE; | 
| 109 | break; | 121 | break; | 
| 110 | case 64: | 122 | case 64: | 
