From: Mark Rutland <mark.rutland@arm.com>
To: Jinbum Park <jinb.park7@gmail.com>
Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
x86@kernel.org, keescook@chromium.org, arjan@linux.intel.com,
akpm@linuxfoundation.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, labbott@redhat.com,
kernel-hardening@lists.openwall.com,
kernel-janitors@vger.kernel.org, linux@armlinux.org.uk
Subject: Re: [PATCH v3] mm: add arch-independent testcases for RODATA
Date: Tue, 24 Jan 2017 18:41:59 +0000 [thread overview]
Message-ID: <20170124184159.GH7572@leverpostej> (raw)
In-Reply-To: <20170124160434.GA23547@pjb1027-Latitude-E5410>
On Wed, Jan 25, 2017 at 01:04:34AM +0900, Jinbum Park wrote:
> This patch makes arch-independent testcases for RODATA.
> Both x86 and x86_64 already have testcases for RODATA,
> But they are arch-specific because using inline assembly directly.
>
> and cacheflush.h is not suitable location for rodata-test related things.
> Since they were in cacheflush.h,
> If someone change the state of CONFIG_DEBUG_RODATA_TEST,
> It cause overhead of kernel build.
>
> To solve above issue,
> Move x86's testcases to shared location able to be called by other archs.
> and move declaration of rodata_test_data to separate header file.
>
> Signed-off-by: Jinbum Park <jinb.park7@gmail.com>
> ---
> v3: Use probe_kernel_write() instead of put_user()
> Move declaration of rodata_test_data to separate header (rodata_test.h)
> Fix a kbuild-test-robot-error related to DEBUG_NX_TEST
>
> v2: Restore original credit of mm/rodata_test.c
>
> arch/x86/Kconfig.debug | 10 +-----
> arch/x86/include/asm/cacheflush.h | 10 ------
> arch/x86/kernel/Makefile | 1 -
> arch/x86/kernel/test_rodata.c | 75 ---------------------------------------
> arch/x86/mm/init_32.c | 4 +--
> arch/x86/mm/init_64.c | 4 +--
> include/linux/rodata_test.h | 24 +++++++++++++
> mm/Kconfig.debug | 7 ++++
> mm/Makefile | 1 +
> mm/rodata_test.c | 63 ++++++++++++++++++++++++++++++++
> 10 files changed, 98 insertions(+), 101 deletions(-)
> delete mode 100644 arch/x86/kernel/test_rodata.c
> create mode 100644 include/linux/rodata_test.h
> create mode 100644 mm/rodata_test.c
> diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
> index 928d657..874b57c 100644
> --- a/arch/x86/mm/init_32.c
> +++ b/arch/x86/mm/init_32.c
> @@ -51,6 +51,7 @@
> #include <asm/cacheflush.h>
> #include <asm/page_types.h>
> #include <asm/init.h>
> +#include <linux/rodata_test.h>
> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> index 5fff913..663d475 100644
> --- a/arch/x86/mm/init_64.c
> +++ b/arch/x86/mm/init_64.c
> @@ -54,6 +54,7 @@
> #include <asm/init.h>
> #include <asm/uv/uv.h>
> #include <asm/setup.h>
> +#include <linux/rodata_test.h>
Rather than fixing up the include here, could we move the rodata_test()
call out into mark_readonly()? e.g.
diff --git a/init/main.c b/init/main.c
index b0c9d6f..d72a8d0 100644
--- a/init/main.c
+++ b/init/main.c
@@ -82,6 +82,7 @@
#include <linux/proc_ns.h>
#include <linux/io.h>
#include <linux/cache.h>
+#include <linux/rodata_test.h>
#include <asm/io.h>
#include <asm/bugs.h>
@@ -937,10 +938,12 @@ static int __init set_debug_rodata(char *str)
#ifdef CONFIG_DEBUG_RODATA
static void mark_readonly(void)
{
- if (rodata_enabled)
+ if (rodata_enabled) {
mark_rodata_ro();
- else
+ rodata_test();
+ } else {
pr_info("Kernel memory protection disabled.\n");
+ }
}
#else
static inline void mark_readonly(void)
... that would remove a few lines of code, and we wouldn't have to add
more in other architectures.
I've given this a go with that applied on arm64. It reported success,
and with mark_rodata_ro() hacked out it detected that .rodata was
writeable.
Thanks,
Mark.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2017-01-24 18:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-24 16:04 Jinbum Park
2017-01-24 18:41 ` Mark Rutland [this message]
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=20170124184159.GH7572@leverpostej \
--to=mark.rutland@arm.com \
--cc=akpm@linuxfoundation.org \
--cc=arjan@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jinb.park7@gmail.com \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=labbott@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@armlinux.org.uk \
--cc=mingo@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox