linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Igor Stoppa <igor.stoppa@gmail.com>
Cc: Andy Lutomirski <luto@amacapital.net>,
	Kees Cook <keescook@chromium.org>,
	igor.stoppa@huawei.com, Nadav Amit <nadav.amit@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	linux-integrity@vger.kernel.org,
	kernel-hardening@lists.openwall.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/6] __wr_after_init: write rare for static allocation
Date: Wed, 5 Dec 2018 20:44:13 -0800	[thread overview]
Message-ID: <20181206044413.GB24603@bombadil.infradead.org> (raw)
In-Reply-To: <20181204121805.4621-3-igor.stoppa@huawei.com>

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;
> +	unsigned long offset;
> +	unsigned long wr_poking_addr;
> +
> +	/* Confirm that the writable mapping exists. */
> +	BUG_ON(!wr_ready);
> +
> +	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)&__start_wr_after_init;
> +	wr_poking_addr = wr_poking_base + offset;
> +	local_irq_save(flags);

Why not local_irq_disable()?  Do we have a use-case for wanting to access
this from interrupt context?

> +	/* XXX make the verification optional? */

Well, yes.  It seems like debug code to me.

> +	/* Randomize the poking address base*/
> +	wr_poking_base = TASK_UNMAPPED_BASE +
> +		(kaslr_get_random_long("Write Rare Poking") & PAGE_MASK) %
> +		(TASK_SIZE - (TASK_UNMAPPED_BASE + wr_range));

I don't think this is a great idea.  We want to use the same mm for both
static and dynamic wr memory, yes?  So we should have enough space for
all of ram, not splatter the static section all over the address space.

On x86-64 (4 level page tables), we have a 64TB space for all of physmem
and 128TB of user space, so we can place the base anywhere in a 64TB
range.


  parent reply	other threads:[~2018-12-06  4:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-04 12:17 [RFC v1 PATCH 0/6] hardening: statically allocated protected memory Igor Stoppa
2018-12-04 12:18 ` [PATCH 1/6] __wr_after_init: linker section and label Igor Stoppa
2018-12-04 12:18 ` [PATCH 2/6] __wr_after_init: write rare for static allocation Igor Stoppa
2018-12-05 23:13   ` Andy Lutomirski
2018-12-06  9:44     ` Peter Zijlstra
2018-12-09 22:32       ` Igor Stoppa
2018-12-10  9:59         ` Peter Zijlstra
2018-12-09 22:09     ` Igor Stoppa
2018-12-12  9:49     ` Martin Schwidefsky
2018-12-19 22:50       ` Igor Stoppa
2018-12-06  4:44   ` Matthew Wilcox [this message]
2018-12-09 22:22     ` Igor Stoppa
2018-12-04 12:18 ` [PATCH 3/6] rodata_test: refactor tests Igor Stoppa
2018-12-04 12:18 ` [PATCH 4/6] rodata_test: add verification for __wr_after_init Igor Stoppa
2018-12-04 12:18 ` [PATCH 5/6] __wr_after_init: test write rare functionality Igor Stoppa
2018-12-04 12:18 ` [PATCH 6/6] __wr_after_init: lkdtm test Igor Stoppa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181206044413.GB24603@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=igor.stoppa@gmail.com \
    --cc=igor.stoppa@huawei.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@amacapital.net \
    --cc=nadav.amit@gmail.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).