Date: Sat, 19 Aug 2017 21:00:03 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322706 - head/sys/i386/i386 Message-ID: <201708192100.v7JL03tm020423@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Sat Aug 19 21:00:02 2017 New Revision: 322706 URL: https://svnweb.freebsd.org/changeset/base/322706 Log: Use the known valid segment when accessing memory in #UD handler. Make sure that %eflags.D flag is cleared for hook. Improve comments. When #UD dtrace code checks for a registered hook before checking that the exception was raised from kernel mode, we might run with the user %ds, trapping on access. Exception entry from userspace automatically load valid %ss, which we can use there instead. Noted and reviewed by: bde Sponsored by: The FreeBSD Foundation MFC after: 3 days Modified: head/sys/i386/i386/exception.s Modified: head/sys/i386/i386/exception.s ============================================================================== --- head/sys/i386/i386/exception.s Sat Aug 19 19:33:16 2017 (r322705) +++ head/sys/i386/i386/exception.s Sat Aug 19 21:00:02 2017 (r322706) @@ -183,12 +183,16 @@ calltrap: #ifdef KDTRACE_HOOKS SUPERALIGN_TEXT IDTVEC(ill) - /* Check if there is no DTrace hook registered. */ - cmpl $0,dtrace_invop_jump_addr + /* + * Check if a DTrace hook is registered. The default (data) segment + * cannot be used for this since %ds is not known good until we + * verify that the entry was from kernel mode. + */ + cmpl $0,%ss:dtrace_invop_jump_addr je norm_ill /* - * Check if this is a user fault. If so, just handle it as a normal + * Check if this is a user fault. If so, just handle it as a normal * trap. */ cmpl $GSEL_KPL, 4(%esp) /* Check the code segment */ @@ -200,7 +204,8 @@ IDTVEC(ill) * This is a kernel instruction fault that might have been caused * by a DTrace provider. */ - pushal /* Push all registers onto the stack. */ + pushal + cld /* * Set our jump address for the jump back in the event that
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708192100.v7JL03tm020423>