LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 2/3] x86:add missing CONFIG_STRICT_KERNEL_RWX for mark_rodata_ro
@ 2018-05-28 3:33 nixiaoming
0 siblings, 0 replies; 5+ messages in thread
From: nixiaoming @ 2018-05-28 3:33 UTC (permalink / raw)
To: tglx, mingo, hpa, akpm, vbabka, mhocko, dave.hansen,
dan.j.williams, kirill.shutemov, zhang.jia
Cc: nixiaoming, linux-kernel, x86
Signed-off-by: nixiaoming <nixiaoming@huawei.com>
---
arch/x86/mm/init_32.c | 2 ++
arch/x86/mm/init_64.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index c893c6a..121c567 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -920,6 +920,7 @@ static void mark_nxdata_nx(void)
set_pages_nx(virt_to_page(start), size >> PAGE_SHIFT);
}
+#ifdef CONFIG_STRICT_KERNEL_RWX
void mark_rodata_ro(void)
{
unsigned long start = PFN_ALIGN(_text);
@@ -957,3 +958,4 @@ void mark_rodata_ro(void)
if (__supported_pte_mask & _PAGE_NX)
debug_checkwx();
}
+#endif /*end of CONFIG_STRICT_KERNEL_RWX*/
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 0a40060..1b7a1a7 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1245,6 +1245,7 @@ void set_kernel_text_ro(void)
set_memory_ro(start, (end - start) >> PAGE_SHIFT);
}
+#ifdef CONFIG_STRICT_KERNEL_RWX
void mark_rodata_ro(void)
{
unsigned long start = PFN_ALIGN(_text);
@@ -1298,6 +1299,7 @@ void mark_rodata_ro(void)
*/
pti_clone_kernel_text();
}
+#endif
int kern_addr_valid(unsigned long addr)
{
--
2.10.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/3] x86:add missing CONFIG_STRICT_KERNEL_RWX for mark_rodata_ro
@ 2018-05-29 13:36 nixiaoming
2018-05-30 5:58 ` Ingo Molnar
0 siblings, 1 reply; 5+ messages in thread
From: nixiaoming @ 2018-05-29 13:36 UTC (permalink / raw)
To: catalin.marinas, will.deacon, ard.biesheuvel, marc.zyngier,
james.morse, kristina.martsenko, steve.capper, tglx, mingo, hpa,
akpm, vbabka, mhocko, dave.hansen, dan.j.williams,
kirill.shutemov, zhang.jia, schwidefsky, heiko.carstens, gregkh
Cc: nixiaoming, linux-kernel, linux-arm-kernel, x86, linux-s390
mark_rodata_ro is only called by the function mark_readonly
when CONFIG_STRICT_KERNEL_RWX=y
if CONFIG_STRICT_KERNEL_RWX is not set
a compile warning may be triggered: unused function
Signed-off-by: nixiaoming <nixiaoming@huawei.com>
---
arch/x86/mm/init_32.c | 2 ++
arch/x86/mm/init_64.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index c893c6a..121c567 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -920,6 +920,7 @@ static void mark_nxdata_nx(void)
set_pages_nx(virt_to_page(start), size >> PAGE_SHIFT);
}
+#ifdef CONFIG_STRICT_KERNEL_RWX
void mark_rodata_ro(void)
{
unsigned long start = PFN_ALIGN(_text);
@@ -957,3 +958,4 @@ void mark_rodata_ro(void)
if (__supported_pte_mask & _PAGE_NX)
debug_checkwx();
}
+#endif /*end of CONFIG_STRICT_KERNEL_RWX*/
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 0a40060..1b7a1a7 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1245,6 +1245,7 @@ void set_kernel_text_ro(void)
set_memory_ro(start, (end - start) >> PAGE_SHIFT);
}
+#ifdef CONFIG_STRICT_KERNEL_RWX
void mark_rodata_ro(void)
{
unsigned long start = PFN_ALIGN(_text);
@@ -1298,6 +1299,7 @@ void mark_rodata_ro(void)
*/
pti_clone_kernel_text();
}
+#endif
int kern_addr_valid(unsigned long addr)
{
--
2.10.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/3] x86:add missing CONFIG_STRICT_KERNEL_RWX for mark_rodata_ro
2018-05-29 13:36 nixiaoming
@ 2018-05-30 5:58 ` Ingo Molnar
2018-05-30 6:07 ` Ard Biesheuvel
0 siblings, 1 reply; 5+ messages in thread
From: Ingo Molnar @ 2018-05-30 5:58 UTC (permalink / raw)
To: nixiaoming
Cc: catalin.marinas, will.deacon, ard.biesheuvel, marc.zyngier,
james.morse, kristina.martsenko, steve.capper, tglx, mingo, hpa,
akpm, vbabka, mhocko, dave.hansen, dan.j.williams,
kirill.shutemov, zhang.jia, schwidefsky, heiko.carstens, gregkh,
linux-kernel, linux-arm-kernel, x86, linux-s390
* nixiaoming <nixiaoming@huawei.com> wrote:
> mark_rodata_ro is only called by the function mark_readonly
> when CONFIG_STRICT_KERNEL_RWX=y
>
> if CONFIG_STRICT_KERNEL_RWX is not set
> a compile warning may be triggered: unused function
>
> Signed-off-by: nixiaoming <nixiaoming@huawei.com>
> ---
> arch/x86/mm/init_32.c | 2 ++
> arch/x86/mm/init_64.c | 2 ++
> 2 files changed, 4 insertions(+)
>
> diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
> index c893c6a..121c567 100644
> --- a/arch/x86/mm/init_32.c
> +++ b/arch/x86/mm/init_32.c
> @@ -920,6 +920,7 @@ static void mark_nxdata_nx(void)
> set_pages_nx(virt_to_page(start), size >> PAGE_SHIFT);
> }
>
> +#ifdef CONFIG_STRICT_KERNEL_RWX
> void mark_rodata_ro(void)
> {
> unsigned long start = PFN_ALIGN(_text);
> @@ -957,3 +958,4 @@ void mark_rodata_ro(void)
> if (__supported_pte_mask & _PAGE_NX)
> debug_checkwx();
> }
> +#endif /*end of CONFIG_STRICT_KERNEL_RWX*/
> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> index 0a40060..1b7a1a7 100644
> --- a/arch/x86/mm/init_64.c
> +++ b/arch/x86/mm/init_64.c
> @@ -1245,6 +1245,7 @@ void set_kernel_text_ro(void)
> set_memory_ro(start, (end - start) >> PAGE_SHIFT);
> }
>
> +#ifdef CONFIG_STRICT_KERNEL_RWX
> void mark_rodata_ro(void)
> {
> unsigned long start = PFN_ALIGN(_text);
> @@ -1298,6 +1299,7 @@ void mark_rodata_ro(void)
> */
> pti_clone_kernel_text();
> }
> +#endif
NAK, this is very ugly and the changelog doesn't appear to be true: the build
warning does not trigger in the default build, correct?
Thanks,
Ingo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/3] x86:add missing CONFIG_STRICT_KERNEL_RWX for mark_rodata_ro
2018-05-30 5:58 ` Ingo Molnar
@ 2018-05-30 6:07 ` Ard Biesheuvel
2018-05-30 6:51 ` Nixiaoming
0 siblings, 1 reply; 5+ messages in thread
From: Ard Biesheuvel @ 2018-05-30 6:07 UTC (permalink / raw)
To: Ingo Molnar
Cc: nixiaoming, Catalin Marinas, Will Deacon, Marc Zyngier,
James Morse, Kristina Martsenko, Steve Capper, Thomas Gleixner,
Ingo Molnar, H. Peter Anvin, Andrew Morton, Vlastimil Babka,
Michal Hocko, Dave Hansen, Williams, Dan J, Kirill A. Shutemov,
zhang.jia, Martin Schwidefsky, Heiko Carstens,
Greg Kroah-Hartman, Linux Kernel Mailing List, linux-arm-kernel,
the arch/x86 maintainers, linux-s390
On 30 May 2018 at 07:58, Ingo Molnar <mingo@kernel.org> wrote:
>
> * nixiaoming <nixiaoming@huawei.com> wrote:
>
>> mark_rodata_ro is only called by the function mark_readonly
>> when CONFIG_STRICT_KERNEL_RWX=y
>>
>> if CONFIG_STRICT_KERNEL_RWX is not set
>> a compile warning may be triggered: unused function
>>
>> Signed-off-by: nixiaoming <nixiaoming@huawei.com>
>> ---
>> arch/x86/mm/init_32.c | 2 ++
>> arch/x86/mm/init_64.c | 2 ++
>> 2 files changed, 4 insertions(+)
>>
>> diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
>> index c893c6a..121c567 100644
>> --- a/arch/x86/mm/init_32.c
>> +++ b/arch/x86/mm/init_32.c
>> @@ -920,6 +920,7 @@ static void mark_nxdata_nx(void)
>> set_pages_nx(virt_to_page(start), size >> PAGE_SHIFT);
>> }
>>
>> +#ifdef CONFIG_STRICT_KERNEL_RWX
>> void mark_rodata_ro(void)
>> {
>> unsigned long start = PFN_ALIGN(_text);
>> @@ -957,3 +958,4 @@ void mark_rodata_ro(void)
>> if (__supported_pte_mask & _PAGE_NX)
>> debug_checkwx();
>> }
>> +#endif /*end of CONFIG_STRICT_KERNEL_RWX*/
>> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
>> index 0a40060..1b7a1a7 100644
>> --- a/arch/x86/mm/init_64.c
>> +++ b/arch/x86/mm/init_64.c
>> @@ -1245,6 +1245,7 @@ void set_kernel_text_ro(void)
>> set_memory_ro(start, (end - start) >> PAGE_SHIFT);
>> }
>>
>> +#ifdef CONFIG_STRICT_KERNEL_RWX
>> void mark_rodata_ro(void)
>> {
>> unsigned long start = PFN_ALIGN(_text);
>> @@ -1298,6 +1299,7 @@ void mark_rodata_ro(void)
>> */
>> pti_clone_kernel_text();
>> }
>> +#endif
>
> NAK, this is very ugly and the changelog doesn't appear to be true: the build
> warning does not trigger in the default build, correct?
>
I don't see how the build warning could trigger at all, given that
mark_rodata_ro() has external linkage.
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH 2/3] x86:add missing CONFIG_STRICT_KERNEL_RWX for mark_rodata_ro
2018-05-30 6:07 ` Ard Biesheuvel
@ 2018-05-30 6:51 ` Nixiaoming
0 siblings, 0 replies; 5+ messages in thread
From: Nixiaoming @ 2018-05-30 6:51 UTC (permalink / raw)
To: Ard Biesheuvel, Ingo Molnar
Cc: Catalin Marinas, Will Deacon, Marc Zyngier, James Morse,
Kristina Martsenko, Steve Capper, Thomas Gleixner, Ingo Molnar,
H. Peter Anvin, Andrew Morton, Vlastimil Babka, Michal Hocko,
Dave Hansen, Williams, Dan J, Kirill A. Shutemov, zhang.jia,
Martin Schwidefsky, Heiko Carstens, Greg Kroah-Hartman,
Linux Kernel Mailing List, linux-arm-kernel,
the arch/x86 maintainers, linux-s390
On 30 May 2018 at 2:07PM Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] wrote:
>On 30 May 2018 at 07:58, Ingo Molnar <mingo@kernel.org> wrote:
>>
>> * nixiaoming <nixiaoming@huawei.com> wrote:
>>
>>> mark_rodata_ro is only called by the function mark_readonly
>>> when CONFIG_STRICT_KERNEL_RWX=y
>>>
>>> if CONFIG_STRICT_KERNEL_RWX is not set
>>> a compile warning may be triggered: unused function
>....
>>
>> NAK, this is very ugly and the changelog doesn't appear to be true: the build
>> warning does not trigger in the default build, correct?
>>
>
>I don't see how the build warning could trigger at all, given that
>mark_rodata_ro() has external linkage.
>
Unable to set CONFIG_STRICT_KERNEL_RWX=n by make menuconfig ARCH=x86_64
the build warning does not trigger in the default build,
but it should be more appropriate to add CONFIG control to the code.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-05-30 6:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-28 3:33 [PATCH 2/3] x86:add missing CONFIG_STRICT_KERNEL_RWX for mark_rodata_ro nixiaoming
2018-05-29 13:36 nixiaoming
2018-05-30 5:58 ` Ingo Molnar
2018-05-30 6:07 ` Ard Biesheuvel
2018-05-30 6:51 ` Nixiaoming
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).