Re: [PATCH 02/17] prmem: write rare for static allocation

2018-10-29 Thread Igor Stoppa
On 26/10/2018 10:41, Peter Zijlstra wrote: On Wed, Oct 24, 2018 at 12:34:49AM +0300, Igor Stoppa wrote: +static __always_inline That's far too large for inline. The reason for it is that it's supposed to minimize the presence of gadgets that might be used in JOP attacks. I am ready to st

Re: [PATCH 02/17] prmem: write rare for static allocation

2018-10-29 Thread Igor Stoppa
On 25/10/2018 01:24, Dave Hansen wrote: +static __always_inline bool __is_wr_after_init(const void *ptr, size_t size) +{ + size_t start = (size_t)&__start_wr_after_init; + size_t end = (size_t)&__end_wr_after_init; + size_t low = (size_t)ptr; + size_t high = (size_t)ptr +

Re: [PATCH 02/17] prmem: write rare for static allocation

2018-10-26 Thread Peter Zijlstra
On Wed, Oct 24, 2018 at 12:34:49AM +0300, Igor Stoppa wrote: > +static __always_inline That's far too large for inline. > +bool wr_memset(const void *dst, const int c, size_t n_bytes) > +{ > + size_t size; > + unsigned long flags; > + uintptr_t d = (uintptr_t)dst; > + > + if (WARN

Re: [PATCH 02/17] prmem: write rare for static allocation

2018-10-24 Thread Dave Hansen
> +static __always_inline bool __is_wr_after_init(const void *ptr, size_t size) > +{ > + size_t start = (size_t)&__start_wr_after_init; > + size_t end = (size_t)&__end_wr_after_init; > + size_t low = (size_t)ptr; > + size_t high = (size_t)ptr + size; > + > + return likely(start

[PATCH 02/17] prmem: write rare for static allocation

2018-10-23 Thread Igor Stoppa
Implementation of write rare for statically allocated data, located in a specific memory section through the use of the __write_rare label. The basic functions are wr_memcpy() and wr_memset(): the write rare counterparts of memcpy() and memset() respectively. To minimize chances of attacks, this