Author: kib
Date: Sat Jul  8 11:07:39 2017
New Revision: 320804
URL: https://svnweb.freebsd.org/changeset/base/320804

Log:
  Fix handling of one more possible exception on return to usermode.
  
  If %ss is loaded with a segment pointing to a non-present descriptor
  by the IRETD instruction, a kernel-mode #SS exception is generated.
  Resulting T_STKFLT trap must be checked against doreti_iret_fault
  location and handled, otherwise userspace may panic the kernel.
  
  Note that this is i386 variant of FreeBSD-SA-15:21.amd64, but unlike
  amd64, there is no swapgs on i386 and the issue is arguably not
  exploitable.
  
  Reported by:  Maxime Villard <[email protected]>
  Tested by:    pho
  Sponsored by: The FreeBSD Foundation
  MFC after:    1 week

Modified:
  head/sys/i386/i386/trap.c

Modified: head/sys/i386/i386/trap.c
==============================================================================
--- head/sys/i386/i386/trap.c   Sat Jul  8 11:06:27 2017        (r320803)
+++ head/sys/i386/i386/trap.c   Sat Jul  8 11:07:39 2017        (r320804)
@@ -550,11 +550,7 @@ user_trctrap_out:
                                        vm86_trap((struct vm86frame *)frame);
                                goto out;
                        }
-                       if (type == T_STKFLT)
-                               break;
-
                        /* FALL THROUGH */
-
                case T_SEGNPFLT:        /* segment not present fault */
                        if (curpcb->pcb_flags & PCB_VM86CALL)
                                break;
@@ -595,6 +591,9 @@ user_trctrap_out:
                                frame->tf_eip = (int)doreti_iret_fault;
                                goto out;
                        }
+                       if (type == T_STKFLT)
+                               break;
+
                        if (frame->tf_eip == (int)doreti_popl_ds) {
                                frame->tf_eip = (int)doreti_popl_ds_fault;
                                goto out;
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to