From: Atish Patra <atish.patra@wdc.com>
To: linux-kernel@vger.kernel.org
Cc: Atish Patra <atish.patra@wdc.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Albert Ou <aou@eecs.berkeley.edu>,
Anup Patel <anup.patel@wdc.com>, Ard Biesheuvel <ardb@kernel.org>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
linux-riscv@lists.infradead.org,
Nick Desaulniers <ndesaulniers@gooogle.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
Sebastien Van Cauwenberghe <svancau@gmail.com>,
Zong Li <zong.li@sifive.com>
Subject: [PATCH 1/3] RISC-V: Fix .init section permission update
Date: Fri, 29 Jan 2021 11:00:36 -0800 [thread overview]
Message-ID: <20210129190038.1001626-1-atish.patra@wdc.com> (raw)
.init section permission should only updated to non-execute if
STRICT_KERNEL_RWX is enabled. Otherwise, this will lead to a kernel hang.
Fixes: 19a00869028f ("RISC-V: Protect all kernel sections including init early")
Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Atish Patra <atish.patra@wdc.com>
---
arch/riscv/kernel/setup.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index 3fa3f26dde85..c7c0655dd45b 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -293,6 +293,8 @@ void free_initmem(void)
unsigned long init_begin = (unsigned long)__init_begin;
unsigned long init_end = (unsigned long)__init_end;
- set_memory_rw_nx(init_begin, (init_end - init_begin) >> PAGE_SHIFT);
+ if (IS_ENABLED(CONFIG_STRICT_KERNEL_RWX))
+ set_memory_rw_nx(init_begin, (init_end - init_begin) >> PAGE_SHIFT);
+
free_initmem_default(POISON_FREE_INITMEM);
}
--
2.25.1
next reply other threads:[~2021-01-29 19:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-29 19:00 Atish Patra [this message]
2021-01-29 19:00 ` [PATCH 2/3] riscv: Align on L1_CACHE_BYTES when STRICT_KERNEL_RWX Atish Patra
2021-02-03 2:34 ` Palmer Dabbelt
2021-01-29 19:00 ` [PATCH 3/3] RISC-V: Define MAXPHYSMEM_1GB only for RV32 Atish Patra
2021-02-03 2:34 ` Palmer Dabbelt
2021-02-03 2:34 ` [PATCH 1/3] RISC-V: Fix .init section permission update Palmer Dabbelt
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=20210129190038.1001626-1-atish.patra@wdc.com \
--to=atish.patra@wdc.com \
--cc=anup.patel@wdc.com \
--cc=aou@eecs.berkeley.edu \
--cc=ardb@kernel.org \
--cc=geert@linux-m68k.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=ndesaulniers@gooogle.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=svancau@gmail.com \
--cc=zong.li@sifive.com \
/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).