lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87zi19gjof.fsf@xps13.shealevy.com>
Date:   Wed, 09 May 2018 07:20:00 -0400
From:   Shea Levy <shea@...alevy.com>
To:     Palmer Dabbelt <palmer@...ive.com>
Cc:     linux-riscv@...ts.infradead.org, albert@...ive.com,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] RISC-V: Load modules within relative jump range of the kernel text.

Hi Palmer,

Shea Levy <shea@...alevy.com> writes:

> Hi Palmer,
>
> Palmer Dabbelt <palmer@...ive.com> writes:
>
>> On Sun, 22 Apr 2018 05:53:56 PDT (-0700), shea@...alevy.com wrote:
>>> Hi Palmer,
>>>
>>> Shea Levy <shea@...alevy.com> writes:
>>>
>>>> Signed-off-by: Shea Levy <shea@...alevy.com>
>>>> ---
>>>>
>>>> Note that this patch worked in my old modules patchset and seems to be
>>>> working now, but my kernel boot locks up on top of
>>>> riscv-for-linus-4.17-mw0 and I don't know if it's due to this patch or
>>>> something else that's changed in the mean time.
>>>>
>>>> ---
>>>>  arch/riscv/include/asm/pgtable.h |  9 +++++++++
>>>>  arch/riscv/kernel/module.c       | 11 +++++++++++
>>>>  2 files changed, 20 insertions(+)
>>>>
>>>> diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
>>>> index 16301966d65b..b08ded13364a 100644
>>>> --- a/arch/riscv/include/asm/pgtable.h
>>>> +++ b/arch/riscv/include/asm/pgtable.h
>>>> @@ -25,6 +25,7 @@
>>>>  #include <asm/page.h>
>>>>  #include <asm/tlbflush.h>
>>>>  #include <linux/mm_types.h>
>>>> +#include <linux/sizes.h>
>>>>  
>>>>  #ifdef CONFIG_64BIT
>>>>  #include <asm/pgtable-64.h>
>>>> @@ -425,6 +426,14 @@ static inline void pgtable_cache_init(void)
>>>>  #define TASK_SIZE VMALLOC_START
>>>>  #endif
>>>>  
>>>> +/*
>>>> + * The module space lives between the addresses given by TASK_SIZE
>>>> + * and PAGE_OFFSET - it must be within 2G of the kernel text.
>>>> + */
>>>> +#define MODULES_SIZE		(SZ_128M)
>>>> +#define MODULES_VADDR		(PAGE_OFFSET - MODULES_SIZE)
>>>> +#define MODULES_END		(VMALLOC_END)
>>>> +
>>>>  #include <asm-generic/pgtable.h>
>>>>  
>>>>  #endif /* !__ASSEMBLY__ */
>>>> diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c
>>>> index 5dddba301d0a..1b382c7de095 100644
>>>> --- a/arch/riscv/kernel/module.c
>>>> +++ b/arch/riscv/kernel/module.c
>>>> @@ -16,6 +16,8 @@
>>>>  #include <linux/err.h>
>>>>  #include <linux/errno.h>
>>>>  #include <linux/moduleloader.h>
>>>> +#include <linux/vmalloc.h>
>>>> +#include <asm/pgtable.h>
>>>>  
>>>>  static int apply_r_riscv_64_rela(struct module *me, u32 *location, Elf_Addr v)
>>>>  {
>>>> @@ -382,3 +384,12 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
>>>>  
>>>>  	return 0;
>>>>  }
>>>> +
>>>> +void *module_alloc(unsigned long size)
>>>> +{
>>>> +	return __vmalloc_node_range(size, 1, MODULES_VADDR,
>>>> +				    MODULES_END, GFP_KERNEL,
>>>> +				    PAGE_KERNEL_EXEC, 0,
>>>> +				    NUMA_NO_NODE,
>>>> +				    __builtin_return_address(0));
>>>> +}
>>>> -- 
>>>> 2.16.2
>>>
>>> Any thoughts on this?
>>
>> The concept looks good, but does this actually keep the modules within 2GiB of 
>> the text if PAGE_OFFSET is large?
>
> It's been some time since I wrote this, but I thought PAGE_OFFSET was
> where the kernel text *started*? So unless the text itself is bigger
> than 2G - 128 M, in which case we're SOL anyway, it seems like this
> should work. Is there something better we can do, without a large memory
> model?
>
> Thanks,
> Shea

Any further thoughts on this?

Thanks,
Shea

Download attachment "signature.asc" of type "application/pgp-signature" (833 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ