* [PATCH v3] arch/x86: get rid of KERN_CONT in show_fault_oops()
@ 2018-06-26 7:28 Dmitry Vyukov
2018-06-26 17:36 ` Andy Shevchenko
2018-06-26 20:05 ` Ingo Molnar
0 siblings, 2 replies; 4+ messages in thread
From: Dmitry Vyukov @ 2018-06-26 7:28 UTC (permalink / raw)
To: tglx, mingo, x86, linux-kernel, sergey.senozhatsky.work, andy.shevchenko
Cc: Dmitry Vyukov
From: Dmitry Vyukov <dvyukov@google.com>
KERN_CONT leads to split lines in kernel output
and complicates useful changes to printk like
printing context before each line.
Only acceptable use of continuations is basically
boot-time testing.
Get rid of it.
Also tidy up code around as asked by reviewers.
Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
Changes since v1:
- use pr_alert() instead of printk(KERN_ALERT)
Changes since v2:
- drop unnecessary parenthesis
- remove once used nx_warning and smep_warning
---
arch/x86/mm/fault.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 9a84a0d08727..a73575cacfd9 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -641,11 +641,6 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
return 0;
}
-static const char nx_warning[] = KERN_CRIT
-"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
-static const char smep_warning[] = KERN_CRIT
-"unable to execute userspace code (SMEP?) (uid: %d)\n";
-
static void
show_fault_oops(struct pt_regs *regs, unsigned long error_code,
unsigned long address)
@@ -664,20 +659,18 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
pte = lookup_address_in_pgd(pgd, address, &level);
if (pte && pte_present(*pte) && !pte_exec(*pte))
- printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
+ pr_crit("kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n",
+ from_kuid(&init_user_ns, current_uid()));
if (pte && pte_present(*pte) && pte_exec(*pte) &&
(pgd_flags(*pgd) & _PAGE_USER) &&
(__read_cr4() & X86_CR4_SMEP))
- printk(smep_warning, from_kuid(&init_user_ns, current_uid()));
+ pr_crit("unable to execute userspace code (SMEP?) (uid: %d)\n",
+ from_kuid(&init_user_ns, current_uid()));
}
- printk(KERN_ALERT "BUG: unable to handle kernel ");
- if (address < PAGE_SIZE)
- printk(KERN_CONT "NULL pointer dereference");
- else
- printk(KERN_CONT "paging request");
-
- printk(KERN_CONT " at %px\n", (void *) address);
+ pr_alert("BUG: unable to handle kernel %s at %px\n",
+ address < PAGE_SIZE ? "NULL pointer dereference" :
+ "paging request", (void *) address);
dump_pagetable(address);
}
--
2.18.0.rc2.346.g013aa6912e-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3] arch/x86: get rid of KERN_CONT in show_fault_oops()
2018-06-26 7:28 [PATCH v3] arch/x86: get rid of KERN_CONT in show_fault_oops() Dmitry Vyukov
@ 2018-06-26 17:36 ` Andy Shevchenko
2018-06-26 20:05 ` Ingo Molnar
1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2018-06-26 17:36 UTC (permalink / raw)
To: Dmitry Vyukov
Cc: Thomas Gleixner, Ingo Molnar,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
Linux Kernel Mailing List, Sergey Senozhatsky, Dmitry Vyukov
On Tue, Jun 26, 2018 at 10:28 AM, Dmitry Vyukov <dvyukov@gmail.com> wrote:
> From: Dmitry Vyukov <dvyukov@google.com>
>
> KERN_CONT leads to split lines in kernel output
> and complicates useful changes to printk like
> printing context before each line.
>
> Only acceptable use of continuations is basically
> boot-time testing.
>
> Get rid of it.
>
> Also tidy up code around as asked by reviewers.
>
FWIW,
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
> Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
>
> ---
>
> Changes since v1:
> - use pr_alert() instead of printk(KERN_ALERT)
>
> Changes since v2:
> - drop unnecessary parenthesis
> - remove once used nx_warning and smep_warning
> ---
> arch/x86/mm/fault.c | 21 +++++++--------------
> 1 file changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
> index 9a84a0d08727..a73575cacfd9 100644
> --- a/arch/x86/mm/fault.c
> +++ b/arch/x86/mm/fault.c
> @@ -641,11 +641,6 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
> return 0;
> }
>
> -static const char nx_warning[] = KERN_CRIT
> -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
> -static const char smep_warning[] = KERN_CRIT
> -"unable to execute userspace code (SMEP?) (uid: %d)\n";
> -
> static void
> show_fault_oops(struct pt_regs *regs, unsigned long error_code,
> unsigned long address)
> @@ -664,20 +659,18 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
> pte = lookup_address_in_pgd(pgd, address, &level);
>
> if (pte && pte_present(*pte) && !pte_exec(*pte))
> - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
> + pr_crit("kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n",
> + from_kuid(&init_user_ns, current_uid()));
> if (pte && pte_present(*pte) && pte_exec(*pte) &&
> (pgd_flags(*pgd) & _PAGE_USER) &&
> (__read_cr4() & X86_CR4_SMEP))
> - printk(smep_warning, from_kuid(&init_user_ns, current_uid()));
> + pr_crit("unable to execute userspace code (SMEP?) (uid: %d)\n",
> + from_kuid(&init_user_ns, current_uid()));
> }
>
> - printk(KERN_ALERT "BUG: unable to handle kernel ");
> - if (address < PAGE_SIZE)
> - printk(KERN_CONT "NULL pointer dereference");
> - else
> - printk(KERN_CONT "paging request");
> -
> - printk(KERN_CONT " at %px\n", (void *) address);
> + pr_alert("BUG: unable to handle kernel %s at %px\n",
> + address < PAGE_SIZE ? "NULL pointer dereference" :
> + "paging request", (void *) address);
>
> dump_pagetable(address);
> }
> --
> 2.18.0.rc2.346.g013aa6912e-goog
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] arch/x86: get rid of KERN_CONT in show_fault_oops()
2018-06-26 7:28 [PATCH v3] arch/x86: get rid of KERN_CONT in show_fault_oops() Dmitry Vyukov
2018-06-26 17:36 ` Andy Shevchenko
@ 2018-06-26 20:05 ` Ingo Molnar
2018-06-27 9:07 ` Dmitry Vyukov
1 sibling, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2018-06-26 20:05 UTC (permalink / raw)
To: Dmitry Vyukov
Cc: tglx, mingo, x86, linux-kernel, sergey.senozhatsky.work,
andy.shevchenko, Dmitry Vyukov
* Dmitry Vyukov <dvyukov@gmail.com> wrote:
> From: Dmitry Vyukov <dvyukov@google.com>
>
> KERN_CONT leads to split lines in kernel output
> and complicates useful changes to printk like
> printing context before each line.
>
> Only acceptable use of continuations is basically
> boot-time testing.
>
> Get rid of it.
>
> Also tidy up code around as asked by reviewers.
>
> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
> Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
>
> ---
>
> Changes since v1:
> - use pr_alert() instead of printk(KERN_ALERT)
>
> Changes since v2:
> - drop unnecessary parenthesis
> - remove once used nx_warning and smep_warning
> ---
> arch/x86/mm/fault.c | 21 +++++++--------------
> 1 file changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
> index 9a84a0d08727..a73575cacfd9 100644
> --- a/arch/x86/mm/fault.c
> +++ b/arch/x86/mm/fault.c
> @@ -641,11 +641,6 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
> return 0;
> }
>
> -static const char nx_warning[] = KERN_CRIT
> -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
> -static const char smep_warning[] = KERN_CRIT
> -"unable to execute userspace code (SMEP?) (uid: %d)\n";
> -
> static void
> show_fault_oops(struct pt_regs *regs, unsigned long error_code,
> unsigned long address)
> @@ -664,20 +659,18 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
> pte = lookup_address_in_pgd(pgd, address, &level);
>
> if (pte && pte_present(*pte) && !pte_exec(*pte))
> - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
> + pr_crit("kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n",
> + from_kuid(&init_user_ns, current_uid()));
> if (pte && pte_present(*pte) && pte_exec(*pte) &&
> (pgd_flags(*pgd) & _PAGE_USER) &&
> (__read_cr4() & X86_CR4_SMEP))
> - printk(smep_warning, from_kuid(&init_user_ns, current_uid()));
> + pr_crit("unable to execute userspace code (SMEP?) (uid: %d)\n",
> + from_kuid(&init_user_ns, current_uid()));
> }
>
> - printk(KERN_ALERT "BUG: unable to handle kernel ");
> - if (address < PAGE_SIZE)
> - printk(KERN_CONT "NULL pointer dereference");
> - else
> - printk(KERN_CONT "paging request");
> -
> - printk(KERN_CONT " at %px\n", (void *) address);
> + pr_alert("BUG: unable to handle kernel %s at %px\n",
> + address < PAGE_SIZE ? "NULL pointer dereference" :
> + "paging request", (void *) address);
I already applied the last hunk in a bit different way - could you send the rest
as a separate clean-up patch please?
Thanks,
Ingo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] arch/x86: get rid of KERN_CONT in show_fault_oops()
2018-06-26 20:05 ` Ingo Molnar
@ 2018-06-27 9:07 ` Dmitry Vyukov
0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Vyukov @ 2018-06-27 9:07 UTC (permalink / raw)
To: Ingo Molnar
Cc: Dmitry Vyukov, Thomas Gleixner, Ingo Molnar,
the arch/x86 maintainers, LKML, Sergey Senozhatsky,
Andy Shevchenko
On Tue, Jun 26, 2018 at 10:05 PM, Ingo Molnar <mingo@kernel.org> wrote:
>
> * Dmitry Vyukov <dvyukov@gmail.com> wrote:
>
>> From: Dmitry Vyukov <dvyukov@google.com>
>>
>> KERN_CONT leads to split lines in kernel output
>> and complicates useful changes to printk like
>> printing context before each line.
>>
>> Only acceptable use of continuations is basically
>> boot-time testing.
>>
>> Get rid of it.
>>
>> Also tidy up code around as asked by reviewers.
>>
>> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
>> Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
>>
>> ---
>>
>> Changes since v1:
>> - use pr_alert() instead of printk(KERN_ALERT)
>>
>> Changes since v2:
>> - drop unnecessary parenthesis
>> - remove once used nx_warning and smep_warning
>> ---
>> arch/x86/mm/fault.c | 21 +++++++--------------
>> 1 file changed, 7 insertions(+), 14 deletions(-)
>>
>> diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
>> index 9a84a0d08727..a73575cacfd9 100644
>> --- a/arch/x86/mm/fault.c
>> +++ b/arch/x86/mm/fault.c
>> @@ -641,11 +641,6 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
>> return 0;
>> }
>>
>> -static const char nx_warning[] = KERN_CRIT
>> -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
>> -static const char smep_warning[] = KERN_CRIT
>> -"unable to execute userspace code (SMEP?) (uid: %d)\n";
>> -
>> static void
>> show_fault_oops(struct pt_regs *regs, unsigned long error_code,
>> unsigned long address)
>> @@ -664,20 +659,18 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
>> pte = lookup_address_in_pgd(pgd, address, &level);
>>
>> if (pte && pte_present(*pte) && !pte_exec(*pte))
>> - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
>> + pr_crit("kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n",
>> + from_kuid(&init_user_ns, current_uid()));
>> if (pte && pte_present(*pte) && pte_exec(*pte) &&
>> (pgd_flags(*pgd) & _PAGE_USER) &&
>> (__read_cr4() & X86_CR4_SMEP))
>> - printk(smep_warning, from_kuid(&init_user_ns, current_uid()));
>> + pr_crit("unable to execute userspace code (SMEP?) (uid: %d)\n",
>> + from_kuid(&init_user_ns, current_uid()));
>> }
>>
>> - printk(KERN_ALERT "BUG: unable to handle kernel ");
>> - if (address < PAGE_SIZE)
>> - printk(KERN_CONT "NULL pointer dereference");
>> - else
>> - printk(KERN_CONT "paging request");
>> -
>> - printk(KERN_CONT " at %px\n", (void *) address);
>> + pr_alert("BUG: unable to handle kernel %s at %px\n",
>> + address < PAGE_SIZE ? "NULL pointer dereference" :
>> + "paging request", (void *) address);
>
> I already applied the last hunk in a bit different way - could you send the rest
> as a separate clean-up patch please?
Just mailed "arch/x86: cleanup show_fault_oops()".
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-06-27 9:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-26 7:28 [PATCH v3] arch/x86: get rid of KERN_CONT in show_fault_oops() Dmitry Vyukov
2018-06-26 17:36 ` Andy Shevchenko
2018-06-26 20:05 ` Ingo Molnar
2018-06-27 9:07 ` Dmitry Vyukov
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.