linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/kernel/process_32: Convert a smp_processor_id() call
@ 2017-05-28  9:22 Borislav Petkov
  2017-05-29  8:16 ` [tip:x86/urgent] x86/debug/32: Convert a smp_processor_id() call to raw to avoid DEBUG_PREEMPT warning tip-bot for Borislav Petkov
  0 siblings, 1 reply; 2+ messages in thread
From: Borislav Petkov @ 2017-05-28  9:22 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: x86-ml, lkml

Hi,

this is on 32-bit with tip/master.

I *think* the solution is as straight-forward but pls double-check me on
that.

Thanks.

---
From: Borislav Petkov <bp@suse.de>
Date: Sun, 28 May 2017 11:03:42 +0200
Subject: [PATCH] x86/kernel/process_32: Convert a smp_processor_id() call

... to raw_smp_processor_id() to not trip the

  BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1

check. The reasoning behind it is that __warn() already uses the raw_
variants but the show_regs() path on 32-bit doesn't.

Otherwise, you get splat in a splat:

 Write protecting the kernel read-only data: 2980k
 NX-protecting the kernel data: 4744k
 x86/mm: Found insecure W+X mapping at address c00a0000/0xc00a0000
 ------------[ cut here ]------------
 WARNING: CPU: 0 PID: 1 at .../arch/x86/mm/dump_pagetables.c:236 note_page+0x6ca/0x8e0
 Modules linked in:
 CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.12.0-rc2+ #1
 Hardware name: LENOVO 30515QG/30515QG, BIOS 8RET30WW (1.12 ) 09/15/2011
 task: f4120000 task.stack: f411a000
 EIP: note_page+0x6ca/0x8e0
 BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1
 caller is debug_smp_processor_id
 CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.12.0-rc2+ #1
 Hardware name: LENOVO 30515QG/30515QG, BIOS 8RET30WW (1.12 ) 09/15/2011
 Call Trace:
  dump_stack
  check_preemption_disabled
  debug_smp_processor_id
  __show_regs
  ? note_page
  ? printk
  ? show_regs_print_info
  ? note_page
  show_regs
  ? vprintk_func
  ? note_page
  __warn
  ? note_page
  ? note_page
  report_bug
  do_trap
  ? do_error_trap
  ? __this_cpu_preempt_check
  ? trace_hardirqs_on_caller
  do_error_trap
  ? note_page
  ? wake_up_klogd
  ? console_unlock
  ? common_exception
  ? do_overflow
  ? __this_cpu_preempt_check
  ? trace_hardirqs_off_caller
  ? do_overflow
  do_invalid_op
  common_exception
 EIP: note_page+0x6ca/0x8e0
 EFLAGS: 00210286 CPU: 0
 EAX: 00000041 EBX: f411bf40 ECX: 00000000 EDX: c10bd629
 ESI: 80000000 EDI: 00000000 EBP: f411bf0c ESP: f411bed4
  DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
  ? wake_up_klogd
  ? do_overflow
  ? change_page_attr_set_clr
  ptdump_walk_pgd_level_core
  ptdump_walk_pgd_level_checkwx
  mark_rodata_ro
  ? rest_init
  kernel_init
  ? schedule_tail_wrapper
  ret_from_fork
 EFLAGS: 00210286 CPU: 0
 EAX: 00000041 EBX: f411bf40 ECX: 00000000 EDX: c10bd629
 ESI: 80000000 EDI: 00000000 EBP: f411bf0c ESP: f411bed4
  DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
 CR0: 80050033 CR2: ffbff000 CR3: 01bbe000 CR4: 000006f0
 Call Trace:
  ? change_page_attr_set_clr
  ptdump_walk_pgd_level_core
  ptdump_walk_pgd_level_checkwx
  mark_rodata_ro
  ? rest_init
  kernel_init
  ? schedule_tail_wrapper
  ret_from_fork
 ---[ end trace e1a49e2b8e42d056 ]---
 x86/mm: Checked W+X mappings: FAILED, 96 W+X pages found.

Signed-off-by: Borislav Petkov <bp@suse.de>
---
 arch/x86/kernel/process_32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index ff40e74c9181..ffeae818aa7a 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -78,7 +78,7 @@ void __show_regs(struct pt_regs *regs, int all)
 
 	printk(KERN_DEFAULT "EIP: %pS\n", (void *)regs->ip);
 	printk(KERN_DEFAULT "EFLAGS: %08lx CPU: %d\n", regs->flags,
-		smp_processor_id());
+		raw_smp_processor_id());
 
 	printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
 		regs->ax, regs->bx, regs->cx, regs->dx);
-- 
2.11.0


-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [tip:x86/urgent] x86/debug/32: Convert a smp_processor_id() call to raw to avoid DEBUG_PREEMPT warning
  2017-05-28  9:22 [PATCH] x86/kernel/process_32: Convert a smp_processor_id() call Borislav Petkov
@ 2017-05-29  8:16 ` tip-bot for Borislav Petkov
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Borislav Petkov @ 2017-05-29  8:16 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jpoimboe, bp, mingo, hpa, peterz, torvalds, linux-kernel, tglx

Commit-ID:  5d9070b1f0fc9a159a9a3240c43004828408444b
Gitweb:     http://git.kernel.org/tip/5d9070b1f0fc9a159a9a3240c43004828408444b
Author:     Borislav Petkov <bp@suse.de>
AuthorDate: Sun, 28 May 2017 11:03:42 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 29 May 2017 08:22:49 +0200

x86/debug/32: Convert a smp_processor_id() call to raw to avoid DEBUG_PREEMPT warning

... to raw_smp_processor_id() to not trip the

  BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1

check. The reasoning behind it is that __warn() already uses the raw_
variants but the show_regs() path on 32-bit doesn't.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20170528092212.fiod7kygpjm23m3o@pd.tnic
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/process_32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index ff40e74..ffeae81 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -78,7 +78,7 @@ void __show_regs(struct pt_regs *regs, int all)
 
 	printk(KERN_DEFAULT "EIP: %pS\n", (void *)regs->ip);
 	printk(KERN_DEFAULT "EFLAGS: %08lx CPU: %d\n", regs->flags,
-		smp_processor_id());
+		raw_smp_processor_id());
 
 	printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
 		regs->ax, regs->bx, regs->cx, regs->dx);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-29  8:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-28  9:22 [PATCH] x86/kernel/process_32: Convert a smp_processor_id() call Borislav Petkov
2017-05-29  8:16 ` [tip:x86/urgent] x86/debug/32: Convert a smp_processor_id() call to raw to avoid DEBUG_PREEMPT warning tip-bot for Borislav Petkov

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).