Skip to content

Commit

Permalink
[libc] Fix longstanding signal handling bug with improperly set DS re…
Browse files Browse the repository at this point in the history
…gister
  • Loading branch information
ghaerr committed Jan 20, 2025
1 parent 1fb2a47 commit 3d4300d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions elks/arch/i86/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ void arch_setup_user_stack (register struct task_struct * t, word_t entry)
void arch_setup_sighandler_stack(register struct task_struct *t,
__kern_sighandler_t addr,unsigned signr)
{
printk("SIGCB %d: DS %x SS %x\n", t->pid, t->t_regs.ds, t->t_regs.ss);
debug("Stack %x:%x was %x %x %x %x\n", _FP_SEG(addr), _FP_OFF(addr),
get_ustack(t,0), get_ustack(t,2), get_ustack(t,4), get_ustack(t,6));
put_ustack(t, -6, (int)get_ustack(t,0));
Expand Down
4 changes: 4 additions & 0 deletions libc/system/signalcb.S
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ _signal_cbhandler:
push %dx
push %si
push %di
push %ds
push %es
mov %ss,%ax
mov %ax,%ds

mov 6(%bp),%bx
#ifndef __IA16_CALLCVT_REGPARMCALL
Expand All @@ -43,6 +46,7 @@ _signal_cbhandler:
#endif

pop %es
pop %ds
pop %di
pop %si
pop %dx
Expand Down
2 changes: 2 additions & 0 deletions libc/watcom/asm/signalcb.asm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ __signal_cbhandler proc far
push di
push ds
push es
mov ax,ss ; ensure valid DS (=SS)
mov ds,ax

mov ax,6[bp] ; get signal #
callf _signal_wchandler_ ; call user function from C
Expand Down

0 comments on commit 3d4300d

Please sign in to comment.