[artful] panic in update_stack_state when reading /proc/<pid>/stack on i386

Bug #1747263 reported by Andy Whitcroft on 2018-02-04
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux (Ubuntu)

Bug Description

It seems that when reading /proc/<pid>/stack we can sometimes triggers a panic on i386. This is triggered by an unsafe pointer access when validating the stack in the stack unwinder. This is reproducible in a 4 cpu 32bit VM with the stress-ng /proc stressor.

Andy Whitcroft (apw) wrote :
Download full text (3.4 KiB)

The below commit has been confirmed as the fix for this:

commit 62dd86ac01f9fb6386d7f8c6b389c3ea4582a50a
Author: Josh Poimboeuf <email address hidden>
Date: Mon Oct 9 20:20:02 2017 -0500

    x86/unwind: Fix dereference of untrusted pointer

    Tetsuo Handa and Fengguang Wu reported a panic in the unwinder:

      BUG: unable to handle kernel NULL pointer dereference at 000001f2
      IP: update_stack_state+0xd4/0x340
      *pde = 00000000

      Oops: 0000 [#1] PREEMPT SMP
      CPU: 0 PID: 18728 Comm: 01-cpu-hotplug Not tainted 4.13.0-rc4-00170-gb09be67 #592
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.9.3-20161025_171302-gandalf 04/01/2014
      task: bb0b53c0 task.stack: bb3ac000
      EIP: update_stack_state+0xd4/0x340
      EFLAGS: 00010002 CPU: 0
      EAX: 0000a570 EBX: bb3adccb ECX: 0000f401 EDX: 0000a570
      ESI: 00000001 EDI: 000001ba EBP: bb3adc6b ESP: bb3adc3f
       DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
      CR0: 80050033 CR2: 000001f2 CR3: 0b3a7000 CR4: 00140690
      DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
      DR6: fffe0ff0 DR7: 00000400
      Call Trace:
       ? unwind_next_frame+0xea/0x400
       ? __unwind_start+0xf5/0x180
       ? __save_stack_trace+0x81/0x160
       ? save_stack_trace+0x20/0x30
       ? __lock_acquire+0xfa5/0x12f0
       ? lock_acquire+0x1c2/0x230
       ? tick_periodic+0x3a/0xf0
       ? _raw_spin_lock+0x42/0x50
       ? tick_periodic+0x3a/0xf0
       ? tick_periodic+0x3a/0xf0
       ? debug_smp_processor_id+0x12/0x20
       ? tick_handle_periodic+0x23/0xc0
       ? local_apic_timer_interrupt+0x63/0x70
       ? smp_trace_apic_timer_interrupt+0x235/0x6a0
       ? trace_apic_timer_interrupt+0x37/0x3c
       ? strrchr+0x23/0x50
      Code: 0f 95 c1 89 c7 89 45 e4 0f b6 c1 89 c6 89 45 dc 8b 04 85 98 cb 74 bc 88 4d e3 89 45 f0 83 c0 01 84 c9 89 04 b5 98 cb 74 bc 74 3b <8b> 47 38 8b 57 34 c6 43 1d 01 25 00 00 02 00 83 e2 03 09 d0 83
      EIP: update_stack_state+0xd4/0x340 SS:ESP: 0068:bb3adc3f
      CR2: 00000000000001f2
      ---[ end trace 0d147fd4aba8ff50 ]---
      Kernel panic - not syncing: Fatal exception in interrupt

    On x86-32, after decoding a frame pointer to get a regs address,
    regs_size() dereferences the regs pointer when it checks regs->cs to see
    if the regs are user mode. This is dangerous because it's possible that
    what looks like a decoded frame pointer is actually a corrupt value, and
    we don't want the unwinder to make things worse.

    Instead of calling regs_size() on an unsafe pointer, just assume they're
    kernel regs to start with. Later, once it's safe to access the regs, we
    can do the user mode check and corresponding safety check for the
    remaining two regs.

    Reported-and-tested-by: Tetsuo Handa <email address hidden>
    Reported-and-tested-by: Fengguang Wu <email address hidden>
    Signed-off-by: Josh Poimboeuf <email address hidden>
    Cc: Byungchul Park <email address hidden>
    Cc: LKP <lkp@01.org>
    Cc: Linus Torvalds <email address hidden>
    Cc: Peter Zijlstra <email address hidden>
    Cc: Thomas Gleixner <email address hidden>


Changed in linux (Ubuntu):
status: New → In Progress
Andy Whitcroft (apw) on 2018-02-04
Changed in linux (Ubuntu):
importance: Undecided → High
Changed in linux (Ubuntu Artful):
status: New → Fix Committed

This bug is awaiting verification that the kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification-needed-artful' to 'verification-done-artful'. If the problem still exists, change the tag 'verification-needed-artful' to 'verification-failed-artful'.

If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.

See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you!

tags: added: verification-needed-artful
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers