Re: [RFC PATCH v5 03/12] __wr_after_init: Core and default arch

2019-02-16 Thread Igor Stoppa
On 15/02/2019 10:57, Peter Zijlstra wrote: Where are the comments and Changelog notes ? How is an arch maintainer to be aware of this requirement when adding support for his/her arch? Yes, it will be fixed in the next revision. I've added comment to the core wr_assign function and also to

Re: [RFC PATCH v5 03/12] __wr_after_init: Core and default arch

2019-02-14 Thread Igor Stoppa
On 14/02/2019 13:28, Peter Zijlstra wrote: On Thu, Feb 14, 2019 at 12:41:32AM +0200, Igor Stoppa wrote: [...] +#define wr_rcu_assign_pointer(p, v) ({ \ + smp_mb(); \ + wr_assign(p, v);\ + p

[RFC PATCH v5 05/12] __wr_after_init: x86_64: enable

2019-02-13 Thread Igor Stoppa
Set ARCH_HAS_PRMEM to Y for x86_64 Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed Soliman CC: linux-integr...@vger.kernel.org CC: kernel-harden

[RFC PATCH v5 10/12] __wr_after_init: rodata_test: test __wr_after_init

2019-02-13 Thread Igor Stoppa
The write protection of the __wr_after_init data can be verified with the same methodology used for const data. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC

[RFC PATCH v5 11/12] __wr_after_init: test write rare functionality

2019-02-13 Thread Igor Stoppa
Set of test cases meant to confirm that the write rare functionality works as expected. It can be optionally compiled as module. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago

[RFC PATCH v5 09/12] __wr_after_init: rodata_test: refactor tests

2019-02-13 Thread Igor Stoppa
Refactor the test cases, in preparation for using them also for testing __wr_after_init memory, when available. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC

[RFC PATCH v5 12/12] IMA: turn ima_policy_flags into __wr_after_init

2019-02-13 Thread Igor Stoppa
. __wr_after_init can still provide some protection, at least against simple memory overwrite attacks Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed Soliman

[RFC PATCH v5 08/12] __wr_after_init: lkdtm test

2019-02-13 Thread Igor Stoppa
Verify that trying to modify a variable with the __wr_after_init attribute will cause a crash. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed Soliman CC

[RFC PATCH v5 06/12] __wr_after_init: arm64: enable

2019-02-13 Thread Igor Stoppa
Set ARCH_HAS_PRMEM to Y for arm64 Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed Soliman CC: linux-integr...@vger.kernel.org CC: kernel-harden

[RFC PATCH v5 07/12] __wr_after_init: Documentation: self-protection

2019-02-13 Thread Igor Stoppa
Update the self-protection documentation, to mention also the use of the __wr_after_init attribute. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed

[RFC PATCH v5 00/12] hardening: statically allocated protected memory

2019-02-13 Thread Igor Stoppa
s the entire available address range from user space (128TB - 64TB) * convert BUG() to WARN() * turn verification of written data into debugging option * wr_rcu_assign_pointer() as special case of wr_assign() * example with protection of ima_policy_flags * documentation Igor Stoppa (11): __w

[RFC PATCH v5 02/12] __wr_after_init: linker section and attribute

2019-02-13 Thread Igor Stoppa
ges, since the granularity available for write protection is of one memory page. The functionality is automatically activated by any architecture that sets CONFIG_ARCH_HAS_PRMEM Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: D

[RFC PATCH v5 04/12] __wr_after_init: x86_64: randomize mapping offset

2019-02-13 Thread Igor Stoppa
. This is accomplished by providing arch-specific version of the function __init_wr_base() Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed Soliman CC: linux

[RFC PATCH v5 03/12] __wr_after_init: Core and default arch

2019-02-13 Thread Igor Stoppa
. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed Soliman CC: linux-integr...@vger.kernel.org CC: kernel-harden...@lists.openwall.com CC: linux

Re: [RFC PATCH v4 01/12] __wr_after_init: Core and default arch

2019-02-11 Thread Igor Stoppa
On 12/02/2019 04:39, Matthew Wilcox wrote: On Tue, Feb 12, 2019 at 01:27:38AM +0200, Igor Stoppa wrote: +#ifndef CONFIG_PRMEM [...] +#else + +#include It's a mistake to do conditional includes like this. That way you see include loops with some configs and not others. Our headers

Re: [RFC PATCH v4 00/12] hardening: statically allocated protected memory

2019-02-11 Thread Igor Stoppa
On 12/02/2019 03:26, Kees Cook wrote: On Mon, Feb 11, 2019 at 5:08 PM igor.sto...@gmail.com wrote: On Tue, 12 Feb 2019, 4.47 Kees Cook On Mon, Feb 11, 2019 at 4:37 PM Igor Stoppa wrote: On 12/02/2019 02:09, Kees Cook wrote: On Mon, Feb 11, 2019 at 3:28 PM Igor Stoppa wrote

Re: [RFC PATCH v4 00/12] hardening: statically allocated protected memory

2019-02-11 Thread Igor Stoppa
On 12/02/2019 02:09, Kees Cook wrote: On Mon, Feb 11, 2019 at 3:28 PM Igor Stoppa wrote: [...] Patch-set implementing write-rare memory protection for statically allocated data. It seems like this could be expanded in the future to cover dynamic memory too (i.e. just a separate base

[RFC PATCH v4 03/12] __wr_after_init: x86_64: randomize mapping offset

2019-02-11 Thread Igor Stoppa
. This is accomplished by providing arch-specific version of the function __init_wr_base() Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed Soliman CC: linux

[RFC PATCH v4 08/12] __wr_after_init: lkdtm test

2019-02-11 Thread Igor Stoppa
Verify that trying to modify a variable with the __wr_after_init attribute will cause a crash. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed Soliman CC

[RFC PATCH v4 11/12] __wr_after_init: test write rare functionality

2019-02-11 Thread Igor Stoppa
Set of test cases meant to confirm that the write rare functionality works as expected. It can be optionally compiled as module. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago

[RFC PATCH v4 12/12] IMA: turn ima_policy_flags into __wr_after_init

2019-02-11 Thread Igor Stoppa
. __wr_after_init can still provide some protection, at least against simple memory overwrite attacks Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed Soliman

[RFC PATCH v4 05/12] __wr_after_init: arm64: memset_user()

2019-02-11 Thread Igor Stoppa
code to privide a memset_user() function, which is currently missing. clear_user() is the base for memset_user() Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC

[RFC PATCH v4 02/12] __wr_after_init: x86_64: memset_user()

2019-02-11 Thread Igor Stoppa
code to privide a memset_user() function, which is currently missing. clear_user() is the base for memset_user() Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC

[RFC PATCH v4 06/12] __wr_after_init: arm64: enable

2019-02-11 Thread Igor Stoppa
Set ARCH_HAS_PRMEM to Y for arm64 Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed Soliman CC: linux-integr...@vger.kernel.org CC: kernel-harden

[RFC PATCH v4 01/12] __wr_after_init: Core and default arch

2019-02-11 Thread Igor Stoppa
. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed Soliman CC: linux-integr...@vger.kernel.org CC: kernel-harden...@lists.openwall.com CC: linux

[RFC PATCH v4 04/12] __wr_after_init: x86_64: enable

2019-02-11 Thread Igor Stoppa
Set ARCH_HAS_PRMEM to Y for x86_64 Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed Soliman CC: linux-integr...@vger.kernel.org CC: kernel-harden

[RFC PATCH v4 07/12] __wr_after_init: Documentation: self-protection

2019-02-11 Thread Igor Stoppa
Update the self-protection documentation, to mention also the use of the __wr_after_init attribute. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed

[RFC PATCH v4 09/12] __wr_after_init: rodata_test: refactor tests

2019-02-11 Thread Igor Stoppa
Refactor the test cases, in preparation for using them also for testing __wr_after_init memory, when available. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC

[RFC PATCH v4 10/12] __wr_after_init: rodata_test: test __wr_after_init

2019-02-11 Thread Igor Stoppa
The write protection of the __wr_after_init data can be verified with the same methodology used for const data. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC

[RFC PATCH v4 00/12] hardening: statically allocated protected memory

2019-02-11 Thread Igor Stoppa
() to WARN() * turn verification of written data into debugging option * wr_rcu_assign_pointer() as special case of wr_assign() * example with protection of ima_policy_flags * documentation Igor Stoppa (12): __wr_after_init: Core and default arch __wr_after_init: x86_64: memset_user() __wr

Re: [PATCH 03/12] __wr_after_init: generic header

2018-12-22 Thread Igor Stoppa
On 21/12/2018 21:45, Matthew Wilcox wrote: On Fri, Dec 21, 2018 at 11:38:16AM -0800, Nadav Amit wrote: On Dec 19, 2018, at 1:33 PM, Igor Stoppa wrote: +static inline void *wr_memset(void *p, int c, __kernel_size_t len) +{ + return __wr_op((unsigned long)p, (unsigned long)c, len

Re: [PATCH 03/12] __wr_after_init: generic functionality

2018-12-21 Thread Igor Stoppa
On 21/12/2018 21:43, Matthew Wilcox wrote: On Fri, Dec 21, 2018 at 09:07:54PM +0200, Igor Stoppa wrote: On 21/12/2018 20:41, Matthew Wilcox wrote: On Fri, Dec 21, 2018 at 08:14:14PM +0200, Igor Stoppa wrote: +static inline int memtst(void *p, int c, __kernel_size_t len) I don't

Re: [PATCH 03/12] __wr_after_init: generic functionality

2018-12-21 Thread Igor Stoppa
On 21/12/2018 20:41, Matthew Wilcox wrote: On Fri, Dec 21, 2018 at 08:14:14PM +0200, Igor Stoppa wrote: +static inline int memtst(void *p, int c, __kernel_size_t len) I don't understand why you're verifying that writes actually happen in production code. Sure, write lib/test_wrmem.c

Re: [PATCH 01/12] x86_64: memset_user()

2018-12-21 Thread Igor Stoppa
On 21/12/2018 20:25, Matthew Wilcox wrote: On Fri, Dec 21, 2018 at 08:14:12PM +0200, Igor Stoppa wrote: +unsigned long __memset_user(void __user *addr, int c, unsigned long size) +{ + long __d0; + unsigned long pattern = 0; + int i; + + for (i = 0; i < 8

[PATCH 04/12] __wr_after_init: debug writes

2018-12-21 Thread Igor Stoppa
After each write operation, confirm that it was successful, otherwise generate a warning. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed Soliman CC

[PATCH 11/12] IMA: turn ima_policy_flags into __wr_after_init

2018-12-21 Thread Igor Stoppa
. __wr_after_init can still provide some protection, at least against simple memory overwrite attacks Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed Soliman

[PATCH 10/12] __wr_after_init: test write rare functionality

2018-12-21 Thread Igor Stoppa
Set of test cases meant to confirm that the write rare functionality works as expected. It can be optionally compiled as module. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago

[PATCH 07/12] __wr_after_init: lkdtm test

2018-12-21 Thread Igor Stoppa
Verify that trying to modify a variable with the __wr_after_init attribute will cause a crash. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed Soliman CC

[PATCH 06/12] __wr_after_init: Documentation: self-protection

2018-12-21 Thread Igor Stoppa
Update the self-protection documentation, to mention also the use of the __wr_after_init attribute. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed

[PATCH 02/12] __wr_after_init: linker section and label

2018-12-21 Thread Igor Stoppa
o activate both section and label, the arch must set CONFIG_ARCH_HAS_PRMEM Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed Soliman CC: linux-integr...@vger.

[PATCH 12/12] x86_64: __clear_user as case of __memset_user

2018-12-21 Thread Igor Stoppa
To avoid code duplication, re-use __memset_user(), when clearing user-space memory. The overhead should be minimal (2 extra register assignments) and outside of the writing loop. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees

[PATCH 09/12] rodata_test: add verification for __wr_after_init

2018-12-21 Thread Igor Stoppa
The write protection of the __wr_after_init data can be verified with the same methodology used for const data. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC

[PATCH 08/12] rodata_test: refactor tests

2018-12-21 Thread Igor Stoppa
Refactor the test cases, in preparation for using them also for testing __wr_after_init memory, when available. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC

[PATCH 03/12] __wr_after_init: generic functionality

2018-12-21 Thread Igor Stoppa
of memset() - wr_memcpy(): write rare counterpart of memcpy() - wr_assign(): write rare counterpart of the assignment ('=') operator - wr_rcu_assign_pointer(): write rare counterpart of rcu_assign_pointer() Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter

[PATCH 05/12] __wr_after_init: x86_64: __wr_op

2018-12-21 Thread Igor Stoppa
, in a preemptible system, however the amount of data to be altered is likely to be far smaller than a page. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: Thiago Jung Bauermann CC: Ahmed

[PATCH 01/12] x86_64: memset_user()

2018-12-21 Thread Igor Stoppa
Create x86_64 specific version of memset for user space, based on clear_user(). This will be used for implementing wr_memset() in the __wr_after_init scenario, where write-rare variables have an alternate mapping for writing. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC

Re: [PATCH 04/12] __wr_after_init: x86_64: __wr_op

2018-12-21 Thread Igor Stoppa
On 21/12/2018 19:23, Andy Lutomirski wrote: On Thu, Dec 20, 2018 at 11:19 AM Igor Stoppa wrote: On 20/12/2018 20:49, Matthew Wilcox wrote: I think you're causing yourself more headaches by implementing this "op" function. I probably misinterpreted the initial criticism o

Re: [PATCH 04/12] __wr_after_init: x86_64: __wr_op

2018-12-20 Thread Igor Stoppa
On 20/12/2018 20:49, Matthew Wilcox wrote: I think you're causing yourself more headaches by implementing this "op" function. I probably misinterpreted the initial criticism on my first patchset, about duplication. Somehow, I'm still thinking to the endgame of having higher-level

Re: [PATCH 11/12] IMA: turn ima_policy_flags into __wr_after_init

2018-12-20 Thread Igor Stoppa
Hi, On 20/12/2018 19:30, Thiago Jung Bauermann wrote: Hello Igor, Igor Stoppa writes: diff --git a/security/integrity/ima/ima_init.c b/security/integrity/ima/ima_init.c index 59d834219cd6..5f4e13e671bf 100644 --- a/security/integrity/ima/ima_init.c +++ b/security/integrity/ima/ima_init.c

Re: [PATCH 04/12] __wr_after_init: x86_64: __wr_op

2018-12-20 Thread Igor Stoppa
Hi, On 20/12/2018 19:20, Thiago Jung Bauermann wrote: Hello Igor, +/* + * The following two variables are statically allocated by the linker + * script at the the boundaries of the memory region (rounded up to + * multiples of PAGE_SIZE) reserved for __wr_after_init. + */ +extern long

Re: [PATCH 04/12] __wr_after_init: x86_64: __wr_op

2018-12-20 Thread Igor Stoppa
On 19/12/2018 23:33, Igor Stoppa wrote: + if (WARN_ONCE(op >= WR_OPS_NUMBER, "Invalid WR operation.") || + WARN_ONCE(!is_wr_after_init(dst, len), "Invalid WR range.")) + return (void *)dst; + + offset = dst - (unsigned long)&__star

[PATCH] checkpatch.pl: Improve WARNING on Kconfig help

2018-12-19 Thread Igor Stoppa
pl sources, to figure out the actual test. Signed-off-by: Igor Stoppa CC: Andy Whitcroft CC: Joe Perches CC: Andi Kleen CC: linux-kernel@vger.kernel.org --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index c8

Re: [PATCH 2/6] __wr_after_init: write rare for static allocation

2018-12-19 Thread Igor Stoppa
On 12/12/2018 11:49, Martin Schwidefsky wrote: On Wed, 5 Dec 2018 15:13:56 -0800 Andy Lutomirski wrote: Hi s390 and powerpc people: it would be nice if this generic implementation *worked* on your architectures and that it will allow you to add some straightforward way to add a better

[PATCH 08/12] rodata_test: refactor tests

2018-12-19 Thread Igor Stoppa
Refactor the test cases, in preparation for using them also for testing __wr_after_init memory, when available. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: linux-integr

[PATCH 07/12] __wr_after_init: lkdtm test

2018-12-19 Thread Igor Stoppa
Verify that trying to modify a variable with the __wr_after_init attribute will cause a crash. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: linux-integr...@vger.kernel.org CC: kernel

[PATCH 04/12] __wr_after_init: x86_64: __wr_op

2018-12-19 Thread Igor Stoppa
, in a preemptible system, however the amount of data to be altered is likely to be far smaller than a page. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: linux-integr...@vger.kernel.org

[PATCH 03/12] __wr_after_init: generic header

2018-12-19 Thread Igor Stoppa
counterpart of memcpy() - wr_assign(): write rare counterpart of the assignment ('=') operator - wr_rcu_assign_pointer(): write rare counterpart of rcu_assign_pointer() Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave

[PATCH 05/12] __wr_after_init: x86_64: debug writes

2018-12-19 Thread Igor Stoppa
After each write operation, confirm that it was successful, otherwise generate a warning. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: linux-integr...@vger.kernel.org CC: kernel-harden

[PATCH 10/12] __wr_after_init: test write rare functionality

2018-12-19 Thread Igor Stoppa
Set of test cases meant to confirm that the write rare functionality works as expected. It can be optionally compiled as module. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: linux

[PATCH 11/12] IMA: turn ima_policy_flags into __wr_after_init

2018-12-19 Thread Igor Stoppa
. __wr_after_init can still provide some protection, at least against simple memory overwrite attacks Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: linux-integr...@vger.kernel.org CC: kernel

[PATCH 09/12] rodata_test: add verification for __wr_after_init

2018-12-19 Thread Igor Stoppa
The write protection of the __wr_after_init data can be verified with the same methodology used for const data. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: linux-integr

[PATCH 06/12] __wr_after_init: Documentation: self-protection

2018-12-19 Thread Igor Stoppa
Update the self-protection documentation, to mention also the use of the __wr_after_init attribute. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: linux-integr...@vger.kernel.org CC

[PATCH 12/12] x86_64: __clear_user as case of __memset_user

2018-12-19 Thread Igor Stoppa
To avoid code duplication, re-use __memset_user(), when clearing user-space memory. The overhead should be minimal (2 extra register assignments) and outside of the writing loop. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees

[RFC v2 PATCH 0/12] hardening: statically allocated protected memory

2018-12-19 Thread Igor Stoppa
nel@vger.kernel.org Igor Stoppa (12): [PATCH 01/12] x86_64: memset_user() [PATCH 02/12] __wr_after_init: linker section and label [PATCH 03/12] __wr_after_init: generic header [PATCH 04/12] __wr_after_init: x86_64: __wr_op [PATCH 05/12] __wr_after_init: x86_64: de

[PATCH 01/12] x86_64: memset_user()

2018-12-19 Thread Igor Stoppa
Create x86_64 specific version of memset for user space, based on clear_user(). This will be used for implementing wr_memset() in the __wr_after_init scenario, where write-rare variables have an alternate mapping for writing. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC

[PATCH 02/12] __wr_after_init: linker section and label

2018-12-19 Thread Igor Stoppa
o activate both section and label, the arch must set CONFIG_ARCH_HAS_PRMEM Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: Mimi Zohar CC: linux-integr...@vger.kernel.org CC: kernel-harden...@lists.openw

[PATCH] checkpatch.pl: Improve WARNING on Kconfig help

2018-12-19 Thread Igor Stoppa
pl sources, to figure out the actual test. Signed-off-by: Igor Stoppa CC: Andy Whitcroft CC: Joe Perches CC: linux-kernel@vger.kernel.org --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index c883ec55654f..33

Re: [PATCH] checkpatch.pl: Improve WARNING on Kconfig help

2018-12-19 Thread Igor Stoppa
On 19/12/2018 14:29, Joe Perches wrote: On Wed, 2018-12-19 at 11:59 +, Andy Whitcroft wrote: On Wed, Dec 19, 2018 at 02:44:36AM -0800, Joe Perches wrote: To cover both cases perhaps: "please ensure that this config symbols is described fully (less than

[PATCH] checkpatch.pl: Improve WARNING on Kconfig help

2018-12-19 Thread Igor Stoppa
pl sources, to figure out the actual test. Signed-off-by: Igor Stoppa CC: Andy Whitcroft CC: Joe Perches CC: linux-kernel@vger.kernel.org --- scripts/checkpatch.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index c883ec55654f..e2

Re: [PATCH 2/6] __wr_after_init: write rare for static allocation

2018-12-09 Thread Igor Stoppa
On 06/12/2018 11:44, Peter Zijlstra wrote: On Wed, Dec 05, 2018 at 03:13:56PM -0800, Andy Lutomirski wrote: + if (op == WR_MEMCPY) + memcpy((void *)wr_poking_addr, (void *)src, len); + else if (op == WR_MEMSET) + memset((u8 *)wr_poking_addr, (u8)src,

Re: [PATCH 2/6] __wr_after_init: write rare for static allocation

2018-12-09 Thread Igor Stoppa
On 06/12/2018 06:44, Matthew Wilcox wrote: On Tue, Dec 04, 2018 at 02:18:01PM +0200, Igor Stoppa wrote: +void *__wr_op(unsigned long dst, unsigned long src, __kernel_size_t len, + enum wr_op_type op) +{ + temporary_mm_state_t prev; + unsigned long flags

Re: [PATCH 2/6] __wr_after_init: write rare for static allocation

2018-12-09 Thread Igor Stoppa
On 06/12/2018 01:13, Andy Lutomirski wrote: + kasan_disable_current(); + if (op == WR_MEMCPY) + memcpy((void *)wr_poking_addr, (void *)src, len); + else if (op == WR_MEMSET) + memset((u8 *)wr_poking_addr, (u8)src, len); + else if (op ==

[PATCH 6/6] __wr_after_init: lkdtm test

2018-12-04 Thread Igor Stoppa
Verify that trying to modify a variable with the __wr_after_init modifier wil lcause a crash. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: linux-integr...@vger.kernel.org CC: kernel-harden

[PATCH 6/6] __wr_after_init: lkdtm test

2018-12-04 Thread Igor Stoppa
Verify that trying to modify a variable with the __wr_after_init modifier wil lcause a crash. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: linux-integr...@vger.kernel.org CC: kernel-harden

[PATCH 2/6] __wr_after_init: write rare for static allocation

2018-12-04 Thread Igor Stoppa
, in a preemptible system, however the amount of data to be altered is likely to be far smaller than a page. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: linux-integr...@vger.kernel.org CC: kernel-harden

[PATCH 4/6] rodata_test: add verification for __wr_after_init

2018-12-04 Thread Igor Stoppa
The write protection of the __wr_after_init data can be verified with the same methodology used for const data. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: linux-integr...@vger.kernel.org CC: kernel

[PATCH 5/6] __wr_after_init: test write rare functionality

2018-12-04 Thread Igor Stoppa
Set of test cases meant to confirm that the write rare functionality works as expected. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: linux-integr...@vger.kernel.org CC: kernel-harden

[PATCH 2/6] __wr_after_init: write rare for static allocation

2018-12-04 Thread Igor Stoppa
, in a preemptible system, however the amount of data to be altered is likely to be far smaller than a page. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: linux-integr...@vger.kernel.org CC: kernel-harden

[PATCH 4/6] rodata_test: add verification for __wr_after_init

2018-12-04 Thread Igor Stoppa
The write protection of the __wr_after_init data can be verified with the same methodology used for const data. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: linux-integr...@vger.kernel.org CC: kernel

[PATCH 5/6] __wr_after_init: test write rare functionality

2018-12-04 Thread Igor Stoppa
Set of test cases meant to confirm that the write rare functionality works as expected. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: linux-integr...@vger.kernel.org CC: kernel-harden

[RFC v1 PATCH 0/6] hardening: statically allocated protected memory

2018-12-04 Thread Igor Stoppa
://www.openwall.com/lists/kernel-hardening/2018/11/22/8 [2] https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1793199.html [3] https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1810245.html Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra

[PATCH 1/6] __wr_after_init: linker section and label

2018-12-04 Thread Igor Stoppa
Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: linux-integr...@vger.kernel.org CC: kernel-harden...@lists.openwall.com CC: linux...@kvack.org CC: linux-kernel@vger.kernel.org --- include/asm-generic/vml

[RFC v1 PATCH 0/6] hardening: statically allocated protected memory

2018-12-04 Thread Igor Stoppa
://www.openwall.com/lists/kernel-hardening/2018/11/22/8 [2] https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1793199.html [3] https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1810245.html Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra

[PATCH 1/6] __wr_after_init: linker section and label

2018-12-04 Thread Igor Stoppa
Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: linux-integr...@vger.kernel.org CC: kernel-harden...@lists.openwall.com CC: linux...@kvack.org CC: linux-kernel@vger.kernel.org --- include/asm-generic/vml

[PATCH 3/6] rodata_test: refactor tests

2018-12-04 Thread Igor Stoppa
Refactor the test cases, in preparation for using them also for testing __wr_after_init memory. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: linux-integr...@vger.kernel.org CC: kernel-harden

[PATCH 3/6] rodata_test: refactor tests

2018-12-04 Thread Igor Stoppa
Refactor the test cases, in preparation for using them also for testing __wr_after_init memory. Signed-off-by: Igor Stoppa CC: Andy Lutomirski CC: Nadav Amit CC: Matthew Wilcox CC: Peter Zijlstra CC: Kees Cook CC: Dave Hansen CC: linux-integr...@vger.kernel.org CC: kernel-harden

Re: [PATCH 10/17] prmem: documentation

2018-11-21 Thread Igor Stoppa
Hi, On 13/11/2018 20:36, Andy Lutomirski wrote: On Tue, Nov 13, 2018 at 10:33 AM Igor Stoppa wrote: I forgot one sentence :-( On 13/11/2018 20:31, Igor Stoppa wrote: On 13/11/2018 19:47, Andy Lutomirski wrote: For general rare-writish stuff, I don't think we want IRQs running with them

Re: [PATCH 10/17] prmem: documentation

2018-11-21 Thread Igor Stoppa
Hi, On 13/11/2018 20:36, Andy Lutomirski wrote: On Tue, Nov 13, 2018 at 10:33 AM Igor Stoppa wrote: I forgot one sentence :-( On 13/11/2018 20:31, Igor Stoppa wrote: On 13/11/2018 19:47, Andy Lutomirski wrote: For general rare-writish stuff, I don't think we want IRQs running with them

Re: [PATCH 10/17] prmem: documentation

2018-11-13 Thread Igor Stoppa
On 13/11/2018 19:16, Andy Lutomirski wrote: > On Tue, Nov 13, 2018 at 6:25 AM Igor Stoppa wrote: [...] >> How about having one mm_struct for each writer (core or thread)? >> > > I don't think that helps anything. I think the mm_struct used for > prmem (or rare_wr

Re: [PATCH 10/17] prmem: documentation

2018-11-13 Thread Igor Stoppa
On 13/11/2018 19:16, Andy Lutomirski wrote: > On Tue, Nov 13, 2018 at 6:25 AM Igor Stoppa wrote: [...] >> How about having one mm_struct for each writer (core or thread)? >> > > I don't think that helps anything. I think the mm_struct used for > prmem (or rare_wr

Re: [PATCH 10/17] prmem: documentation

2018-10-31 Thread Igor Stoppa
On 01/11/2018 01:19, Andy Lutomirski wrote: ISTM you don't need that atomic operation -- you could take a spinlock and then just add one directly to the variable. It was my intention to provide a 1:1 conversion of existing code, as it should be easier to verify the correctness of the

Re: [PATCH 10/17] prmem: documentation

2018-10-31 Thread Igor Stoppa
On 01/11/2018 01:19, Andy Lutomirski wrote: ISTM you don't need that atomic operation -- you could take a spinlock and then just add one directly to the variable. It was my intention to provide a 1:1 conversion of existing code, as it should be easier to verify the correctness of the

Re: [PATCH 10/17] prmem: documentation

2018-10-30 Thread Igor Stoppa
On 30/10/2018 23:02, Andy Lutomirski wrote: On Oct 30, 2018, at 1:43 PM, Igor Stoppa wrote: There is no need to process each of these tens of thousands allocations and initialization as write-rare. Would it be possible to do the same here? I don’t see why not, although getting

Re: [PATCH 10/17] prmem: documentation

2018-10-30 Thread Igor Stoppa
On 30/10/2018 23:02, Andy Lutomirski wrote: On Oct 30, 2018, at 1:43 PM, Igor Stoppa wrote: There is no need to process each of these tens of thousands allocations and initialization as write-rare. Would it be possible to do the same here? I don’t see why not, although getting

Build error in drivers/cpufreq/intel_pstate.c

2018-10-30 Thread Igor Stoppa
Hi, I'm getting the following build error: /home/igor/dev/kernel/linux/drivers/cpufreq/intel_pstate.c: In function ‘show_base_frequency’: /home/igor/dev/kernel/linux/drivers/cpufreq/intel_pstate.c:726:10: error: implicit declaration of function ‘intel_pstate_get_cppc_guranteed’; did you mean

Build error in drivers/cpufreq/intel_pstate.c

2018-10-30 Thread Igor Stoppa
Hi, I'm getting the following build error: /home/igor/dev/kernel/linux/drivers/cpufreq/intel_pstate.c: In function ‘show_base_frequency’: /home/igor/dev/kernel/linux/drivers/cpufreq/intel_pstate.c:726:10: error: implicit declaration of function ‘intel_pstate_get_cppc_guranteed’; did you mean

Re: [PATCH 16/17] prmem: pratomic-long

2018-10-29 Thread Igor Stoppa
On 25/10/2018 01:13, Peter Zijlstra wrote: On Wed, Oct 24, 2018 at 12:35:03AM +0300, Igor Stoppa wrote: +static __always_inline +bool __pratomic_long_op(bool inc, struct pratomic_long_t *l) +{ + struct page *page; + uintptr_t base; + uintptr_t offset; + unsigned long

Re: [PATCH 16/17] prmem: pratomic-long

2018-10-29 Thread Igor Stoppa
On 25/10/2018 01:13, Peter Zijlstra wrote: On Wed, Oct 24, 2018 at 12:35:03AM +0300, Igor Stoppa wrote: +static __always_inline +bool __pratomic_long_op(bool inc, struct pratomic_long_t *l) +{ + struct page *page; + uintptr_t base; + uintptr_t offset; + unsigned long

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

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

  1   2   3   4   5   6   7   8   9   >