Skip to contentSkip to conversation

"Exec Shield", new Linux security feature

Announcement Chuck Ebbert 3 participants 3 messages May 4, 2003 – May 5, 2003

lore
Share & tools
lore
#0 lore raw
Quoted 4 lines

btw, I guess that now, at least when X_workaround==1, exploits will focus on getting iopl(2) called before they get the actual shellcode called. In some cases it may be easy to cause a call to iopl (param doesn't matter as long as its not zero).

I looked at sys_iopl() and it seems to be checking if its param is

Quoted 1 line

3, so EBX on the stack must be 0x00000003 to set iopl to 3.

The declaration is misleading ("unused"???:)

asmlinkage int sys_iopl(unsigned long unused)

{
        struct pt_regs * regs = (struct pt_regs *) &unused;       <== yuck!
        unsigned int level = regs->ebx;
        ...
        if (level > 3)
                return -EINVAL;

Shouldnt it be like this?

asmlinkage int sys_iopl (struct pt_regs regs)

{
        unsigned int level = regs.ebx;
        ...

fork, clone, vfork and execve all declare it that way...

#1 lore raw
Quoted 3 lines · Chuck Ebbert

asmlinkage int sys_iopl(unsigned long unused)

{
        struct pt_regs * regs = (struct pt_regs *) &unused;       <== yuck!

[...]

Quoted 3 lines

Shouldnt it be like this?

asmlinkage int sys_iopl (struct pt_regs regs)

No, it should be like

int sys_iopl (struct pt_regs *regs)

and assembly language should push the proper address.

The struct-as-argument form allows the compiler to smash the entire structure as it sees fit.

Quoted 1 line

fork, clone, vfork and execve all declare it that way...

They're all wrong too.

r~

#2 lore raw
Followup to:  <[email protected]>
By author:    Richard Henderson <[email protected]>
In newsgroup: linux.dev.kernel
Quoted 10 lines · Chuck Ebbert
Quoted 3 lines

asmlinkage int sys_iopl(unsigned long unused)

{
        struct pt_regs * regs = (struct pt_regs *) &unused;       <== yuck!

[...]

Quoted 3 lines

Shouldnt it be like this?

asmlinkage int sys_iopl (struct pt_regs regs)

Quoted 9 lines

No, it should be like

int sys_iopl (struct pt_regs *regs)

and assembly language should push the proper address.

The struct-as-argument form allows the compiler to smash the entire structure as it sees fit.

Hardly - it has to correspond to the ABI for the platform."

Presumably that's where the "asmlinkage" piece comes in.

-hpa

Signature · 3 lines
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64