From 8d4a3ad6652e40fbe44cde878c8e0ad0c2c34a94 Mon Sep 17 00:00:00 2001 From: hpa Date: Thu, 18 Aug 2005 21:08:56 +0000 Subject: [PATCH] If onerror is set, invoke onerror on escape --- NEWS | 1 + abort.inc | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ extlinux.asm | 38 ++---------------------------- isolinux.asm | 38 ++---------------------------- ldlinux.asm | 38 ++---------------------------- pxelinux.asm | 37 ++---------------------------- syslinux.doc | 2 +- 7 files changed, 85 insertions(+), 144 deletions(-) create mode 100644 abort.inc diff --git a/NEWS b/NEWS index 4c79b13..a19fd68 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,7 @@ Changes in 3.10: * New API call to do "localboot". * New API call to query features. * Fix for bug in EBIOS code discovered by Arwin Vosselman. + * NOESCAPE security fix. Changes in 3.09: * gcc4 compilation fix. diff --git a/abort.inc b/abort.inc new file mode 100644 index 0000000..3c90597 --- /dev/null +++ b/abort.inc @@ -0,0 +1,75 @@ +; $Id$ +; ----------------------------------------------------------------------- +; +; Copyright 2005 H. Peter Anvin - All Rights Reserved +; +; This program is free software; you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation, Inc., 53 Temple Place Ste 330, +; Boston MA 02111-1307, USA; either version 2 of the License, or +; (at your option) any later version; incorporated herein by reference. +; +; ----------------------------------------------------------------------- + +; +; abort.inc +; +; Code to terminate a kernel load +; + +; +; abort_check: let the user abort with or +; +abort_load equ abort_check.do_abort + +abort_check: + call pollchar + jz .ret1 + pusha + call getchar + cmp al,27 ; + je .kill + cmp al,3 ; + jne .ret2 +.kill: mov si,aborted_msg + + ; ... fall through ... + +; +; abort_load: Called by various routines which wants to print a fatal +; error message and return to the command prompt. Since this +; may happen at just about any stage of the boot process, assume +; our state is messed up, and just reset the segment registers +; and the stack forcibly. +; +; SI = offset (in _text) of error message to print +; +.do_abort: + mov ax,cs ; Restore CS = DS = ES + mov ds,ax + mov es,ax +%if IS_SYSLINUX || IS_EXTLINUX + mov ss,ax ; Just in case... + mov sp,StackBuf-2*3 ; Reset stack +%elif IS_PXELINUX + lss esp,[BaseStack] +%elif IS_ISOLINUX + lss sp,[cs:Stack] +%else + NEED TO KNOW HOW TO RESET STACK +%endif + sti + call cwritestr ; Expects SI -> error msg + + ; If onerror is set, jump to onerror, otherwise return + ; to the command prompt + mov cx,[OnerrorLen] + and cx,cx + jnz on_error + jmp enter_command ; Return to command prompt + +; +; End of abort_check +; +.ret2: popa +.ret1: ret diff --git a/extlinux.asm b/extlinux.asm index 73c9f3f..c7a7381 100644 --- a/extlinux.asm +++ b/extlinux.asm @@ -895,43 +895,9 @@ getlinsec_ext: ret ; -; abort_check: let the user abort with or +; Abort loading code ; -abort_check: - call pollchar - jz ac_ret1 - pusha - call getchar - cmp al,27 ; - je ac_kill - cmp al,3 ; - jne ac_ret2 -ac_kill: mov si,aborted_msg - -; -; abort_load: Called by various routines which wants to print a fatal -; error message and return to the command prompt. Since this -; may happen at just about any stage of the boot process, assume -; our state is messed up, and just reset the segment registers -; and the stack forcibly. -; -; SI = offset (in _text) of error message to print -; -abort_load: - mov ax,cs ; Restore CS = DS = ES - mov ds,ax - mov es,ax - cli - mov sp,StackBuf-2*3 ; Reset stack - mov ss,ax ; Just in case... - sti - call cwritestr ; Expects SI -> error msg -al_ok: jmp enter_command ; Return to command prompt -; -; End of abort_check -; -ac_ret2: popa -ac_ret1: ret +%include "abort.inc" ; ; allocate_file: Allocate a file structure diff --git a/isolinux.asm b/isolinux.asm index cf04243..50f4117 100644 --- a/isolinux.asm +++ b/isolinux.asm @@ -1149,43 +1149,9 @@ local_boot: jmp kaboom ; If we returned, oh boy... ; -; abort_check: let the user abort with or +; Abort loading code ; -abort_check: - call pollchar - jz ac_ret1 - pusha - call getchar - cmp al,27 ; - je ac_kill - cmp al,3 ; - jne ac_ret2 -ac_kill: mov si,aborted_msg - -; -; abort_load: Called by various routines which wants to print a fatal -; error message and return to the command prompt. Since this -; may happen at just about any stage of the boot process, assume -; our state is messed up, and just reset the segment registers -; and the stack forcibly. -; -; SI = offset (in _text) of error message to print -; -abort_load: - mov ax,cs ; Restore CS = DS = ES - mov ds,ax - mov es,ax - cli - lss sp,[cs:Stack] ; Reset the stack - sti - call cwritestr ; Expects SI -> error msg -al_ok: jmp enter_command ; Return to command prompt -; -; End of abort_check -; -ac_ret2: popa -ac_ret1: ret - +%include "abort.inc" ; ; searchdir: diff --git a/ldlinux.asm b/ldlinux.asm index e415e97..1651ae1 100644 --- a/ldlinux.asm +++ b/ldlinux.asm @@ -926,43 +926,9 @@ getfattype: %include "bootsect.inc" ; -; abort_check: let the user abort with or +; Abort loading code ; -abort_check: - call pollchar - jz ac_ret1 - pusha - call getchar - cmp al,27 ; - je ac_kill - cmp al,3 ; - jne ac_ret2 -ac_kill: mov si,aborted_msg - -; -; abort_load: Called by various routines which wants to print a fatal -; error message and return to the command prompt. Since this -; may happen at just about any stage of the boot process, assume -; our state is messed up, and just reset the segment registers -; and the stack forcibly. -; -; SI = offset (in _text) of error message to print -; -abort_load: - mov ax,cs ; Restore CS = DS = ES - mov ds,ax - mov es,ax - cli - mov sp,StackBuf-2*3 ; Reset stack - mov ss,ax ; Just in case... - sti - call cwritestr ; Expects SI -> error msg -al_ok: jmp enter_command ; Return to command prompt -; -; End of abort_check -; -ac_ret2: popa -ac_ret1: ret +%include "abort.inc" ; ; allocate_file: Allocate a file structure diff --git a/pxelinux.asm b/pxelinux.asm index a48093f..13bb79b 100644 --- a/pxelinux.asm +++ b/pxelinux.asm @@ -909,42 +909,9 @@ local_boot: retf ; Return to PXE ; -; abort_check: let the user abort with or +; Abort loading code ; -abort_check: - call pollchar - jz ac_ret1 - pusha - call getchar - cmp al,27 ; - je ac_kill - cmp al,3 ; - jne ac_ret2 -ac_kill: mov si,aborted_msg - -; -; abort_load: Called by various routines which wants to print a fatal -; error message and return to the command prompt. Since this -; may happen at just about any stage of the boot process, assume -; our state is messed up, and just reset the segment registers -; and the stack forcibly. -; -; SI = offset (in _text) of error message to print -; -abort_load: - mov ax,cs ; Restore CS = DS = ES - mov ds,ax - mov es,ax - lss esp,[BaseStack] - sti - call cwritestr ; Expects SI -> error msg -al_ok: jmp enter_command ; Return to command prompt -; -; End of abort_check -; -ac_ret2: popa -ac_ret1: ret - +%include "abort.inc" ; ; kaboom: write a message and bail out. Wait for quite a while, diff --git a/syslinux.doc b/syslinux.doc index 4cd6b33..11c3a25 100644 --- a/syslinux.doc +++ b/syslinux.doc @@ -2,7 +2,7 @@ A suite of bootloaders for Linux - Copyright (C) 1994-2004 H. Peter Anvin + Copyright (C) 1994-2005 H. Peter Anvin This program is provided under the terms of the GNU General Public License, version 2 or, at your option, any later version. There is no -- 2.7.4