All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Kees Cook <keescook@chromium.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Ingo Molnar <mingo@kernel.org>,
	David Brown <david.brown@linaro.org>,
	Andy Lutomirski <luto@amacapital.net>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Mathias Krause <minipli@googlemail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	"x86@kernel.org" <x86@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	PaX Team <pageexec@freemail.hu>, Emese Revfy <re.emese@gmail.com>,
	"kernel-hardening@lists.openwall.com"
	<kernel-hardening@lists.openwall.com>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-arch <linux-arch@vger.kernel.org>,
	linux-s390 <linux-s390@vger.kernel.org>
Subject: [kernel-hardening] Re: [RFC][PATCH] s390, postinit-readonly: implement post-init RO
Date: Tue, 8 Mar 2016 09:51:05 +0100	[thread overview]
Message-ID: <56DE9279.6040805@de.ibm.com> (raw)
In-Reply-To: <CAGXu5jLu5NFw=7xoJEYcAq7MFwGY1nuB8w-q+NVp2d2zpwRUyQ@mail.gmail.com>

On 03/08/2016 01:41 AM, Kees Cook wrote:

>> --- a/arch/s390/kernel/vmlinux.lds.S
>> +++ b/arch/s390/kernel/vmlinux.lds.S
>> @@ -52,6 +52,12 @@ SECTIONS
>>
>>         RW_DATA_SECTION(0x100, PAGE_SIZE, THREAD_SIZE)
>>
>> +       . = ALIGN(PAGE_SIZE)


missing ";" ?


With that  and your fixes, this function claims to mark 0kB and 
lkdtm can still write. Reason is that _edata is 0xc11008 and start is
0x0c11000.

making _edata page aligned as well, does now try to mark one page, but then
we run into the next issue, that 

static void change_page_attr(unsigned long addr, int numpages,
                             pte_t (*set) (pte_t))
{
        pte_t *ptep;
        int i;

        for (i = 0; i < numpages; i++) {
                ptep = walk_page_table(addr);

triggers this
                if (WARN_ON_ONCE(!ptep))
                        break;

because the kernel decided to map this with a large page. So we need
to fix this function to then break the large page into a smaller chunk....

Christian

WARNING: multiple messages have this Message-ID (diff)
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Kees Cook <keescook@chromium.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Ingo Molnar <mingo@kernel.org>,
	David Brown <david.brown@linaro.org>,
	Andy Lutomirski <luto@amacapital.net>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Mathias Krause <minipli@googlemail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	"x86@kernel.org" <x86@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	PaX Team <pageexec@freemail.hu>, Emese Revfy <re.emese@gmail.com>,
	"kernel-hardening@lists.openwall.com"
	<kernel-hardening@lists.openwall.com>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-arch <linux-arch@vger.kernel.org>,
	linux-s390 <linux-s390@vger.kernel.org>
Subject: Re: [RFC][PATCH] s390, postinit-readonly: implement post-init RO
Date: Tue, 8 Mar 2016 09:51:05 +0100	[thread overview]
Message-ID: <56DE9279.6040805@de.ibm.com> (raw)
In-Reply-To: <CAGXu5jLu5NFw=7xoJEYcAq7MFwGY1nuB8w-q+NVp2d2zpwRUyQ@mail.gmail.com>

On 03/08/2016 01:41 AM, Kees Cook wrote:

>> --- a/arch/s390/kernel/vmlinux.lds.S
>> +++ b/arch/s390/kernel/vmlinux.lds.S
>> @@ -52,6 +52,12 @@ SECTIONS
>>
>>         RW_DATA_SECTION(0x100, PAGE_SIZE, THREAD_SIZE)
>>
>> +       . = ALIGN(PAGE_SIZE)


missing ";" ?


With that  and your fixes, this function claims to mark 0kB and 
lkdtm can still write. Reason is that _edata is 0xc11008 and start is
0x0c11000.

making _edata page aligned as well, does now try to mark one page, but then
we run into the next issue, that 

static void change_page_attr(unsigned long addr, int numpages,
                             pte_t (*set) (pte_t))
{
        pte_t *ptep;
        int i;

        for (i = 0; i < numpages; i++) {
                ptep = walk_page_table(addr);

triggers this
                if (WARN_ON_ONCE(!ptep))
                        break;

because the kernel decided to map this with a large page. So we need
to fix this function to then break the large page into a smaller chunk....

Christian

  reply	other threads:[~2016-03-08  8:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-08  0:20 [kernel-hardening] [RFC][PATCH] s390, postinit-readonly: implement post-init RO Kees Cook
2016-03-08  0:20 ` Kees Cook
2016-03-08  0:41 ` [kernel-hardening] " Kees Cook
2016-03-08  0:41   ` Kees Cook
2016-03-08  8:51   ` Christian Borntraeger [this message]
2016-03-08  8:51     ` Christian Borntraeger
2016-03-08 11:43     ` [kernel-hardening] " Heiko Carstens
2016-03-08 11:43       ` Heiko Carstens
2016-03-08 12:56       ` [kernel-hardening] " Heiko Carstens
2016-03-08 12:56         ` Heiko Carstens

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=56DE9279.6040805@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=arnd@arndb.de \
    --cc=david.brown@linaro.org \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hpa@zytor.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=minipli@googlemail.com \
    --cc=mpe@ellerman.id.au \
    --cc=pageexec@freemail.hu \
    --cc=re.emese@gmail.com \
    --cc=schwidefsky@de.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.