Thread: [libposix-development] [PATCH 2/2] x86_32: use 'int 0x80' for system calls to improve protability
Status: Pre-Alpha
Brought to you by:
hdante
From: Kirill A. S. <ki...@sh...> - 2009-06-26 14:44:20
|
Not every kernel provide __kernel_vsyscall. It's possible to add configuration option later. Signed-off-by: Kirill A. Shutemov <ki...@sh...> --- runtime/linux/x86_32/architecture_init.c | 22 +--------------------- system/linux/x86_32/system_calls.S | 17 ++--------------- 2 files changed, 3 insertions(+), 36 deletions(-) diff --git a/runtime/linux/x86_32/architecture_init.c b/runtime/linux/x86_32/architecture_init.c index f080dc4..f3fb6e6 100644 --- a/runtime/linux/x86_32/architecture_init.c +++ b/runtime/linux/x86_32/architecture_init.c @@ -27,28 +27,8 @@ POSSIBILITY OF SUCH DAMAGE. #include <stddef.h> #include "runtime.h" -void (*kernel_vsyscall)(); - -/* AT_SYSINFO entry has the vsyscall address */ -#define AT_SYSINFO 32 - -void set_kernel_vsyscall(const auxv_t *auxv) -{ - if (auxv != NULL) { - const auxv_t *auxv_walk; - for (auxv_walk = auxv; auxv_walk->a_type != 0; auxv_walk++) { - if (auxv_walk->a_type == AT_SYSINFO) { - kernel_vsyscall = auxv_walk->a_un.a_fcn; - return; - - } - } - // ERROR: AT_SYSINFO entry not found - } -} - void architecture_init(int argc, const char **argv, const char **envp, const auxv_t *auxv) { - set_kernel_vsyscall(auxv); + /* Do nothing */ } diff --git a/system/linux/x86_32/system_calls.S b/system/linux/x86_32/system_calls.S index 8e1d6f9..f11f8ca 100644 --- a/system/linux/x86_32/system_calls.S +++ b/system/linux/x86_32/system_calls.S @@ -36,8 +36,6 @@ POSSIBILITY OF SUCH DAMAGE. Paramenter sequence is: %ebx, %ecx, %edx, %esi, %edi and %ebp See, for example: http://www.linuxjournal.com/article/4048 - - TODO: remove calculation for kernel_vsyscall (use a fixed address) */ @@ -45,12 +43,9 @@ syscall1: pushl %ebp movl %esp, %ebp pushl %ebx - call get_abs_address - addl $_GLOBAL_OFFSET_TABLE_, %ebx - movl kernel_vsyscall@GOT(%ebx), %ecx movl 8(%ebp), %eax movl 12(%ebp), %ebx - call *(%ecx) + int $0x80 popl %ebx popl %ebp ret @@ -60,20 +55,12 @@ syscall3: movl %esp, %ebp pushl %edi pushl %ebx - call get_abs_address - addl $_GLOBAL_OFFSET_TABLE_, %ebx - movl kernel_vsyscall@GOT(%ebx), %edi movl 8(%ebp), %eax movl 12(%ebp), %ebx movl 16(%ebp), %ecx movl 20(%ebp), %edx - call *(%edi) + int $0x80 popl %ebx popl %edi popl %ebp ret - -get_abs_address: - mov (%esp), %ebx - ret - -- 1.6.3.3 |
From: Henrique A. <hd...@gm...> - 2009-06-26 17:21:19
|
Thanks for the patch. However, do you need those for linux 2.4 ? If you do, that would be a variant from the default implementation. I'll explain variants when I define platform sets, but the point is that the amount of variants should be kept to a minimum possible. For linux 2.6, vsyscall can always be set and is considered to be the default way to do system calls (because it's faster in modern processors), so a second implementation would be redundant. Also, I wasn't considering supporting linux 2.4 in x86. If someone is willing to switch to libposix to use a newer standard, then probably the person is also willing to update to linux 2.6 ;-) So, if you DEFINITELY need x86 linux 2.4 support in libposix, please resend the patch as a variant: create a subdirectory called "linux24" in system/linux/x86_32 and runtime/linux/x86_32 and create a separate cmake file to support the variant by redefining the necessary support files. 2009/6/26 Kirill A. Shutemov <ki...@sh...>: > Not every kernel provide __kernel_vsyscall. It's possible to add > configuration option later. > > Signed-off-by: Kirill A. Shutemov <ki...@sh...> > --- > runtime/linux/x86_32/architecture_init.c | 22 +--------------------- > system/linux/x86_32/system_calls.S | 17 ++--------------- > 2 files changed, 3 insertions(+), 36 deletions(-) > > diff --git a/runtime/linux/x86_32/architecture_init.c > b/runtime/linux/x86_32/architecture_init.c > index f080dc4..f3fb6e6 100644 > --- a/runtime/linux/x86_32/architecture_init.c > +++ b/runtime/linux/x86_32/architecture_init.c > @@ -27,28 +27,8 @@ POSSIBILITY OF SUCH DAMAGE. > #include <stddef.h> > #include "runtime.h" > > -void (*kernel_vsyscall)(); > - > -/* AT_SYSINFO entry has the vsyscall address */ > -#define AT_SYSINFO 32 > - > -void set_kernel_vsyscall(const auxv_t *auxv) > -{ > - if (auxv != NULL) { > - const auxv_t *auxv_walk; > - for (auxv_walk = auxv; auxv_walk->a_type != 0; auxv_walk++) { > - if (auxv_walk->a_type == AT_SYSINFO) { > - kernel_vsyscall = auxv_walk->a_un.a_fcn; > - return; > - > - } > - } > - // ERROR: AT_SYSINFO entry not found > - } > -} > - > void architecture_init(int argc, const char **argv, const char **envp, > const auxv_t *auxv) > { > - set_kernel_vsyscall(auxv); > + /* Do nothing */ > } > diff --git a/system/linux/x86_32/system_calls.S > b/system/linux/x86_32/system_calls.S > index 8e1d6f9..f11f8ca 100644 > --- a/system/linux/x86_32/system_calls.S > +++ b/system/linux/x86_32/system_calls.S > @@ -36,8 +36,6 @@ POSSIBILITY OF SUCH DAMAGE. > Paramenter sequence is: %ebx, %ecx, %edx, %esi, %edi and %ebp > See, for example: > http://www.linuxjournal.com/article/4048 > - > - TODO: remove calculation for kernel_vsyscall (use a fixed address) > */ > > > @@ -45,12 +43,9 @@ syscall1: > pushl %ebp > movl %esp, %ebp > pushl %ebx > - call get_abs_address > - addl $_GLOBAL_OFFSET_TABLE_, %ebx > - movl kernel_vsyscall@GOT(%ebx), %ecx > movl 8(%ebp), %eax > movl 12(%ebp), %ebx > - call *(%ecx) > + int $0x80 > popl %ebx > popl %ebp > ret > @@ -60,20 +55,12 @@ syscall3: > movl %esp, %ebp > pushl %edi > pushl %ebx > - call get_abs_address > - addl $_GLOBAL_OFFSET_TABLE_, %ebx > - movl kernel_vsyscall@GOT(%ebx), %edi > movl 8(%ebp), %eax > movl 12(%ebp), %ebx > movl 16(%ebp), %ecx > movl 20(%ebp), %edx > - call *(%edi) > + int $0x80 > popl %ebx > popl %edi > popl %ebp > ret > - > -get_abs_address: > - mov (%esp), %ebx > - ret > - > -- > 1.6.3.3 > > ------------------------------------------------------------------------------ > _______________________________________________ > Libposix-development mailing list > Lib...@li... > https://lists.sourceforge.net/lists/listinfo/libposix-development > -- Henrique Dante de Almeida hd...@gm... |
From: Kirill A. S. <ki...@sh...> - 2009-06-26 17:30:07
|
On Fri, Jun 26, 2009 at 8:20 PM, Henrique Almeida<hd...@gm...> wrote: > Thanks for the patch. However, do you need those for linux 2.4 ? No, I use 2.6.30. Config here: http://git.altlinux.org/people/lakostis/packages/?p=kernel-image-2.6.30.git;a=blob;f=config-i586;h=9635402ce20ee00645daeb3ffd1f236fde01e5cd;hb=fc05c2cdc66d7d64a62c5f07df43e25437a5902e I guess it because CONFIG_COMPAT_VDSO=n. |
From: Henrique A. <hd...@gm...> - 2009-06-26 17:33:37
|
Ok, is the config default from your distro ? Or can you turn the vdso on ? 2009/6/26 Kirill A. Shutemov <ki...@sh...>: > On Fri, Jun 26, 2009 at 8:20 PM, Henrique Almeida<hd...@gm...> wrote: >> Thanks for the patch. However, do you need those for linux 2.4 ? > > No, I use 2.6.30. Config here: > > http://git.altlinux.org/people/lakostis/packages/?p=kernel-image-2.6.30.git;a=blob;f=config-i586;h=9635402ce20ee00645daeb3ffd1f236fde01e5cd;hb=fc05c2cdc66d7d64a62c5f07df43e25437a5902e > > I guess it because CONFIG_COMPAT_VDSO=n. > > ------------------------------------------------------------------------------ > _______________________________________________ > Libposix-development mailing list > Lib...@li... > https://lists.sourceforge.net/lists/listinfo/libposix-development > -- Henrique Dante de Almeida hd...@gm... |
From: Kirill A. S. <ki...@sh...> - 2009-06-26 17:37:54
|
On Fri, Jun 26, 2009 at 8:32 PM, Henrique Almeida<hd...@gm...> wrote: > Ok, is the config default from your distro ? Or can you turn the vdso on ? It seems only for compatibility with old glibc: config COMPAT_VDSO def_bool y prompt "Compat VDSO support" depends on X86_32 || IA32_EMULATION ---help--- Map the 32-bit VDSO to the predictable old-style address too. ---help--- Say N here if you are running a sufficiently recent glibc version (2.3.3 or later), to remove the high-mapped VDSO mapping and to exclusively use the randomized VDSO. If unsure, say Y. I don't this that it's right way. |
From: Henrique A. <hd...@gm...> - 2009-06-26 17:35:50
|
Wait, my CONFIG_COMPAT_VDSO is not set either. 2009/6/26 Henrique Almeida <hd...@gm...>: > Ok, is the config default from your distro ? Or can you turn the vdso on ? > > 2009/6/26 Kirill A. Shutemov <ki...@sh...>: >> On Fri, Jun 26, 2009 at 8:20 PM, Henrique Almeida<hd...@gm...> wrote: >>> Thanks for the patch. However, do you need those for linux 2.4 ? >> >> No, I use 2.6.30. Config here: >> >> http://git.altlinux.org/people/lakostis/packages/?p=kernel-image-2.6.30.git;a=blob;f=config-i586;h=9635402ce20ee00645daeb3ffd1f236fde01e5cd;hb=fc05c2cdc66d7d64a62c5f07df43e25437a5902e >> >> I guess it because CONFIG_COMPAT_VDSO=n. >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Libposix-development mailing list >> Lib...@li... >> https://lists.sourceforge.net/lists/listinfo/libposix-development >> > > > > -- > Henrique Dante de Almeida > hd...@gm... > -- Henrique Dante de Almeida hd...@gm... |
From: Henrique A. <hd...@gm...> - 2009-06-26 17:37:05
|
Can you check /proc/sys/vm/vdso_enabled ? 2009/6/26 Henrique Almeida <hd...@gm...>: > Wait, my CONFIG_COMPAT_VDSO is not set either. > > 2009/6/26 Henrique Almeida <hd...@gm...>: >> Ok, is the config default from your distro ? Or can you turn the vdso on ? >> >> 2009/6/26 Kirill A. Shutemov <ki...@sh...>: >>> On Fri, Jun 26, 2009 at 8:20 PM, Henrique Almeida<hd...@gm...> wrote: >>>> Thanks for the patch. However, do you need those for linux 2.4 ? >>> >>> No, I use 2.6.30. Config here: >>> >>> http://git.altlinux.org/people/lakostis/packages/?p=kernel-image-2.6.30.git;a=blob;f=config-i586;h=9635402ce20ee00645daeb3ffd1f236fde01e5cd;hb=fc05c2cdc66d7d64a62c5f07df43e25437a5902e >>> >>> I guess it because CONFIG_COMPAT_VDSO=n. >>> >>> ------------------------------------------------------------------------------ >>> _______________________________________________ >>> Libposix-development mailing list >>> Lib...@li... >>> https://lists.sourceforge.net/lists/listinfo/libposix-development >>> >> >> >> >> -- >> Henrique Dante de Almeida >> hd...@gm... >> > > > > -- > Henrique Dante de Almeida > hd...@gm... > -- Henrique Dante de Almeida hd...@gm... |
From: Kirill A. S. <ki...@sh...> - 2009-06-26 19:53:34
|
On Fri, Jun 26, 2009 at 8:36 PM, Henrique Almeida<hd...@gm...> wrote: > Can you check /proc/sys/vm/vdso_enabled ? I can't reproduce the problem on my home machine. I'll try it on Monday at work. It looks like local misconfiguration. |
From: Henrique A. <hd...@gm...> - 2009-06-26 20:56:44
|
2009/6/26 Kirill A. Shutemov <ki...@sh...>: > On Fri, Jun 26, 2009 at 8:36 PM, Henrique Almeida<hd...@gm...> wrote: >> Can you check /proc/sys/vm/vdso_enabled ? > > I can't reproduce the problem on my home machine. I'll try it on Monday at work. > It looks like local misconfiguration. Ok. Can you send patch 1/2 again ? > > ------------------------------------------------------------------------------ > _______________________________________________ > Libposix-development mailing list > Lib...@li... > https://lists.sourceforge.net/lists/listinfo/libposix-development > -- Henrique Dante de Almeida hd...@gm... |
From: Henrique A. <hd...@gm...> - 2009-07-01 02:17:41
|
Were you able to solve this issue ? 2009/6/26 Kirill A. Shutemov <ki...@sh...>: > On Fri, Jun 26, 2009 at 8:36 PM, Henrique Almeida<hd...@gm...> wrote: >> Can you check /proc/sys/vm/vdso_enabled ? > > I can't reproduce the problem on my home machine. I'll try it on Monday at work. > It looks like local misconfiguration. > > ------------------------------------------------------------------------------ > _______________________________________________ > Libposix-development mailing list > Lib...@li... > https://lists.sourceforge.net/lists/listinfo/libposix-development > -- Henrique Dante de Almeida hd...@gm... |
From: Kirill A. S. <ki...@sh...> - 2009-07-01 07:11:13
|
On Wed, Jul 1, 2009 at 5:10 AM, Henrique Almeida<hd...@gm...> wrote: > Were you able to solve this issue ? Yep. It's local problem. |