Skip to content

Commit

Permalink
[kernel] Remove CONFIG_EXEC_LOW_STACK allowing stack below .data section
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaerr committed Dec 7, 2024
1 parent 1f1c404 commit 672981b
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 39 deletions.
7 changes: 0 additions & 7 deletions elks/arch/i86/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ void stack_check(void)
{
segoff_t end = current->t_endbrk;

#ifdef CONFIG_EXEC_LOW_STACK
if (current->t_begstack <= current->t_enddata) { /* stack below heap?*/
if (current->t_regs.sp < end)
return;
end = 0;
} else
#endif
{
/* optional: check stack over min stack*/
if (current->t_regs.sp < current->t_begstack - current->t_minstack) {
Expand Down
4 changes: 0 additions & 4 deletions elks/arch/i86/mm/malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,6 @@ int sys_brk(segoff_t newbrk)
return -ENOMEM;
}
}
#ifdef CONFIG_EXEC_LOW_STACK
if (newbrk > current->t_endseg)
return -ENOMEM;
#endif
current->t_endbrk = newbrk;

return 0;
Expand Down
28 changes: 0 additions & 28 deletions elks/fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,18 +266,8 @@ static int execve_aout(struct inode *inode, struct file *filp, char *sptr, size_
if (esuph.msh_tbase != 0)
goto error_exec3;
base_data = esuph.msh_dbase;
#ifdef CONFIG_EXEC_LOW_STACK
if (base_data & 0xf)
goto error_exec3;
if (base_data != 0)
debug("EXEC: New type executable stack = %x\n", base_data);

if (add_overflow(min_len, base_data, &min_len)) /* adds stack size*/
goto error_exec3;
#else
if (base_data != 0)
goto error_exec3;
#endif
break;
#endif /* CONFIG_EXEC_MMODEL*/
default:
Expand All @@ -293,9 +283,6 @@ static int execve_aout(struct inode *inode, struct file *filp, char *sptr, size_
goto error_exec3;
case 1:
len = min_len;
#ifdef CONFIG_EXEC_LOW_STACK
if (!base_data)
#endif
{
stack = mh.minstack? mh.minstack: INIT_STACK;
if (add_overflow(len, stack, &len)) { /* add stack */
Expand Down Expand Up @@ -335,14 +322,6 @@ static int execve_aout(struct inode *inode, struct file *filp, char *sptr, size_
} else {
stack = INIT_STACK;
len = min_len;
#ifdef CONFIG_EXEC_LOW_STACK
if (base_data) {
if (add_overflow(len, INIT_HEAP, &len)) {
retval = -EFBIG;
goto error_exec3;
}
} else
#endif
{
if (add_overflow(len, INIT_HEAP + INIT_STACK, &len)) {
retval = -EFBIG;
Expand Down Expand Up @@ -495,14 +474,7 @@ static int execve_aout(struct inode *inode, struct file *filp, char *sptr, size_
currentp->t_enddata = (size_t)mh.dseg + (size_t)mh.bseg + base_data;
currentp->t_endseg = len;
currentp->t_regs.dx = currentp->t_minstack = stack;

#ifdef CONFIG_EXEC_LOW_STACK
currentp->t_begstack = ((base_data /* Just above the top of stack */
? base_data
: currentp->t_endseg) - slen) & ~1;
#else
currentp->t_begstack = (currentp->t_endseg - slen) & ~1; /* force even SP and argv */
#endif
fmemcpyb((char *)currentp->t_begstack, seg_data->base, sptr, ds, slen);

finalize_exec(inode, seg_code, seg_data, (word_t)mh.entry, 0);
Expand Down

0 comments on commit 672981b

Please sign in to comment.