RE: [PATCH v4 3/5] stack: Optionally randomize kernel stack offset each syscall

2020-06-23 Thread David Laight
From: Kees Cook > Sent: 23 June 2020 01:56 > On Mon, Jun 22, 2020 at 08:05:10PM -0400, Arvind Sankar wrote: > > But I still don't see anything _stopping_ the compiler from optimizing > > this better in the future. The "=m" is not a barrier: it just informs > > the compiler that the asm produces an

Re: [PATCH v4 3/5] stack: Optionally randomize kernel stack offset each syscall

2020-06-23 Thread Alexander Popov
On 22.06.2020 22:31, Kees Cook wrote: > As Linux kernel stack protections have been constantly improving > (vmap-based stack allocation with guard pages, removal of thread_info, > STACKLEAK), attackers have had to find new ways for their exploits > to work. They have done so, continuing to rely on

Re: [PATCH v4 3/5] stack: Optionally randomize kernel stack offset each syscall

2020-06-22 Thread Kees Cook
On Mon, Jun 22, 2020 at 08:05:10PM -0400, Arvind Sankar wrote: > But I still don't see anything _stopping_ the compiler from optimizing > this better in the future. The "=m" is not a barrier: it just informs > the compiler that the asm produces an output value in *ptr (and no other > outputs). If n

Re: [PATCH v4 3/5] stack: Optionally randomize kernel stack offset each syscall

2020-06-22 Thread Arvind Sankar
On Mon, Jun 22, 2020 at 04:07:11PM -0700, Kees Cook wrote: > On Mon, Jun 22, 2020 at 06:56:15PM -0400, Arvind Sankar wrote: > > On Mon, Jun 22, 2020 at 12:31:44PM -0700, Kees Cook wrote: > > > + > > > +#define add_random_kstack_offset() do { > > > \ > > > + if (sta

Re: [PATCH v4 3/5] stack: Optionally randomize kernel stack offset each syscall

2020-06-22 Thread Kees Cook
On Mon, Jun 22, 2020 at 06:56:15PM -0400, Arvind Sankar wrote: > On Mon, Jun 22, 2020 at 12:31:44PM -0700, Kees Cook wrote: > > + > > +#define add_random_kstack_offset() do { > > \ > > + if (static_branch_maybe(CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT, \ > > +

Re: [PATCH v4 3/5] stack: Optionally randomize kernel stack offset each syscall

2020-06-22 Thread Arvind Sankar
On Mon, Jun 22, 2020 at 12:31:44PM -0700, Kees Cook wrote: > + > +#define add_random_kstack_offset() do { > \ > + if (static_branch_maybe(CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT, \ > + &randomize_kstack_offset)) {\ > +

Re: [PATCH v4 3/5] stack: Optionally randomize kernel stack offset each syscall

2020-06-22 Thread Kees Cook
On Mon, Jun 22, 2020 at 11:42:29PM +0200, Jann Horn wrote: > No, at least on x86-64 and x86 Linux overrides the normal ABI. From > arch/x86/Makefile: Ah! Thanks for the pointer. > > # For gcc stack alignment is specified with -mpreferred-stack-boundary, > # clang has the option -mstack-alignment

Re: [PATCH v4 3/5] stack: Optionally randomize kernel stack offset each syscall

2020-06-22 Thread Jann Horn
On Mon, Jun 22, 2020 at 11:30 PM Kees Cook wrote: > On Mon, Jun 22, 2020 at 10:07:37PM +0200, Jann Horn wrote: > > On Mon, Jun 22, 2020 at 9:31 PM Kees Cook wrote: > > > This provides the ability for architectures to enable kernel stack base > > > address offset randomization. This feature is con

Re: [PATCH v4 3/5] stack: Optionally randomize kernel stack offset each syscall

2020-06-22 Thread Kees Cook
On Mon, Jun 22, 2020 at 10:07:37PM +0200, Jann Horn wrote: > On Mon, Jun 22, 2020 at 9:31 PM Kees Cook wrote: > > This provides the ability for architectures to enable kernel stack base > > address offset randomization. This feature is controlled by the boot > > param "randomize_kstack_offset=on/o

Re: [PATCH v4 3/5] stack: Optionally randomize kernel stack offset each syscall

2020-06-22 Thread Kees Cook
On Mon, Jun 22, 2020 at 12:40:49PM -0700, Randy Dunlap wrote: > On 6/22/20 12:31 PM, Kees Cook wrote: > > This provides the ability for architectures to enable kernel stack base > > address offset randomization. This feature is controlled by the boot > > param "randomize_kstack_offset=on/off", with

Re: [PATCH v4 3/5] stack: Optionally randomize kernel stack offset each syscall

2020-06-22 Thread Jann Horn
On Mon, Jun 22, 2020 at 9:31 PM Kees Cook wrote: > This provides the ability for architectures to enable kernel stack base > address offset randomization. This feature is controlled by the boot > param "randomize_kstack_offset=on/off", with its default value set by > CONFIG_RANDOMIZE_KSTACK_OFFSET

Re: [PATCH v4 3/5] stack: Optionally randomize kernel stack offset each syscall

2020-06-22 Thread Randy Dunlap
On 6/22/20 12:31 PM, Kees Cook wrote: > This provides the ability for architectures to enable kernel stack base > address offset randomization. This feature is controlled by the boot > param "randomize_kstack_offset=on/off", with its default value set by > CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT. >

[PATCH v4 3/5] stack: Optionally randomize kernel stack offset each syscall

2020-06-22 Thread Kees Cook
This provides the ability for architectures to enable kernel stack base address offset randomization. This feature is controlled by the boot param "randomize_kstack_offset=on/off", with its default value set by CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT. This feature is based on the original idea from