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.
Notify committer of r336876.
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.
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.
Haha, our patches just crossed paths :) Yours seems more complete as I didn't handle the args. I'll try it tomorrow hopefully.
(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.
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
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