Bug 230993 - sysutils/acpi_call: Kernel panic since CURRENT r336876 (Use SMAP on amd64)
Summary: sysutils/acpi_call: Kernel panic since CURRENT r336876 (Use SMAP on amd64)
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Jean-Sébastien Pédron
URL:
Keywords: patch, regression
Depends on:
Blocks:
 
Reported: 2018-08-29 06:00 UTC by Theron Tarigo
Modified: 2018-11-06 14:02 UTC (History)
6 users (show)

See Also:
bugzilla: maintainer-feedback? (gelraen.ua)


Attachments
Fix (1.90 KB, text/plain)
2018-08-29 06:00 UTC, Theron Tarigo
no flags Details
Patch to fix accesses to userland pointers in kernel module (5.26 KB, patch)
2018-09-13 20:25 UTC, Jean-Sébastien Pédron
no flags Details | Diff
patch-acpi__call.c (3.52 KB, text/plain)
2018-09-13 20:45 UTC, D Scott Phillips
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Theron Tarigo 2018-08-29 06:00:30 UTC
Created attachment 196667 [details]
Fix

Using acpi_call on CURRENT since r336876 causes a kernel panic on some hardware.  Investigating the problem reveals an attempt to use a userspace pointer from within the kernel module (passed to the acpi_call_fixup_pointers routine).  This evidently is no longer allowed under use of Supervisor Mode Access Protection.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2018-08-29 14:05:10 UTC
Notify committer of r336876.
Comment 2 Jean-Sébastien Pédron freebsd_committer freebsd_triage 2018-09-13 20:25:35 UTC
Created attachment 197075 [details]
Patch to fix accesses to userland pointers in kernel module

I also hit a kernel panic on a recent laptop (Skylake) with acpi_call, but not on an older one (Haswell) which probably confirms the SMAP cause.

I tried your patch and it was not enough to get rid of the panic because, in my case, the kernel fails to read the `path` located in userland. I had to modify it further to use copyin(9) to get the `path`.

Here is a new patch (to apply to the port directly) which fixes the problem for me. I can turn off the discrete GPU of my laptop using acpi_call. The new patch includes your initial, that's why I marked yours as obsolete.
Comment 3 D Scott Phillips 2018-09-13 20:45:05 UTC
Created attachment 197077 [details]
patch-acpi__call.c

(In reply to Theron Tarigo from comment #0)

I think along with doing the fixup before the copyout, path and args both need copyin'd. I still get smap access violations with your patch, but this one fixes everything for me.
Comment 4 Jean-Sébastien Pédron freebsd_committer freebsd_triage 2018-09-13 22:06:55 UTC
Haha, our patches just crossed paths :) Yours seems more complete as I didn't handle the args. I'll try it tomorrow hopefully.
Comment 5 Daniel Zeisig 2018-10-09 05:04:21 UTC
(In reply to D Scott Phillips from comment #3)
Just tested your patch against FreeBSD-12.0-ALPHA8-amd64-20180928-r338991 on a Huawei MateBook X Pro I7 Kabylake.

I used it disable the discrete Nvidia graphics card. Worked for me. Thank you for sharing.
Comment 6 commit-hook freebsd_committer freebsd_triage 2018-11-05 22:33:37 UTC
A commit references this bug:

Author: dumbbell
Date: Mon Nov  5 22:32:42 UTC 2018
New revision: 484252
URL: https://svnweb.freebsd.org/changeset/ports/484252

Log:
  sysutils/acpi_call: Fix kernel panic since r336876

  PR:		230993
  Submitted by:	D Scott Phillips <d.scott.phillips@intel.com>
  Reported by:	Theron Tarigo <theron.tarigo@gmail.com>
  MFH:		2018Q4

Changes:
  head/sysutils/acpi_call/Makefile
  head/sysutils/acpi_call/files/patch-acpi__call.c
Comment 7 commit-hook freebsd_committer freebsd_triage 2018-11-06 14:02:23 UTC
A commit references this bug:

Author: dumbbell
Date: Tue Nov  6 14:01:39 UTC 2018
New revision: 484290
URL: https://svnweb.freebsd.org/changeset/ports/484290

Log:
  MFH: r484252

  sysutils/acpi_call: Fix kernel panic since r336876

  PR:		230993
  Submitted by:	D Scott Phillips <d.scott.phillips@intel.com>
  Reported by:	Theron Tarigo <theron.tarigo@gmail.com>

  Approved by:	portmgr (miwi)

Changes:
_U  branches/2018Q4/
  branches/2018Q4/sysutils/acpi_call/Makefile
  branches/2018Q4/sysutils/acpi_call/files/patch-acpi__call.c