Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: src/tests/lib/libc



Module Name:    src
Committed By:   jym
Date:           Mon Jul 18 23:16:11 UTC 2011

Modified Files:
        src/tests/lib/libc/sys: Makefile t_mprotect.c
Added Files:
        src/tests/lib/libc/arch: Makefile.exec_prot
        src/tests/lib/libc/arch/alpha: exec_prot_support.c return_one.S
        src/tests/lib/libc/arch/arm: exec_prot_support.c return_one.S
        src/tests/lib/libc/arch/hppa: exec_prot_support.c return_one.S
        src/tests/lib/libc/arch/i386: exec_prot_support.c return_one.S
        src/tests/lib/libc/arch/ia64: exec_prot_support.c return_one.S
        src/tests/lib/libc/arch/m68k: exec_prot_support.c return_one.S
        src/tests/lib/libc/arch/mips: exec_prot_support.c return_one.S
        src/tests/lib/libc/arch/powerpc: exec_prot_support.c return_one.S
        src/tests/lib/libc/arch/powerpc64: exec_prot_support.c return_one.S
        src/tests/lib/libc/arch/sh3: exec_prot_support.c return_one.S
        src/tests/lib/libc/arch/sparc: exec_prot_support.c return_one.S
        src/tests/lib/libc/arch/sparc64: exec_prot_support.c return_one.S
        src/tests/lib/libc/arch/vax: exec_prot_support.c return_one.S
        src/tests/lib/libc/arch/x86_64: exec_prot_support.c return_one.S
        src/tests/lib/libc/common: exec_prot.h

Log Message:
Add a simple test case to check executable mapping rights for mprotect(2).

- provide an exec_prot_support() routine so $ARCH can indicate whether
it supports execution protection or not, and skip test accordingly.

- have a trivial 'return_one' shellcode to copy anywhere in a page, and
call it. The decision to keep the assembly solution is mine, reasons are
twofold:

   - all pure-C implementations cannot be controlled easily:
     bounds detection (beginning/end) of return_one is unpredictable,
     or requires the use of overkill solutions like libelf. Using
     dlsym(3) was a good proposal, however I can't use it to know the
     end address of the payload. It makes copying of the shellcode a bit
     more difficult: using a constant may be too small (code has not been
     entirely copied, and can lead to errors that can be erroneously
     detected as "test passed"), or too big (depending on where it is mapped
     in memory, copying past the end of the function may trigger SIGSEGV).

   - I have to ensure that the resulting assembly is the most compact
     possible, especially as it will be reused to test other parts of
     memory (stack, data, rodata, etc.).

Only i386 and amd64 are implemented so far. Others will come in due time.
FWIW, writing the exec_prot_support() callback and the return_one payload
should be enough. Writing callback requires good knowledge of the platform,
depending on chip revision, CPU, board, MMU... the protection level may vary.

Current files are put under lib/libc/arch/* and lib/libc/common/. Feel free to
move them around the tests/ tree. Keep in mind that the common/ and arch/ code
will be used outside of libc, so please do not hide them too deep in the tree.

I checked a few architectures via build.sh cross-compile, and will keep an
eye on buildbot for potential build breakage. Feel free to contact me in
case you see any, of course.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/arch/Makefile.exec_prot
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/arch/alpha/exec_prot_support.c \
    src/tests/lib/libc/arch/alpha/return_one.S
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/arch/arm/exec_prot_support.c \
    src/tests/lib/libc/arch/arm/return_one.S
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/arch/hppa/exec_prot_support.c \
    src/tests/lib/libc/arch/hppa/return_one.S
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/arch/i386/exec_prot_support.c \
    src/tests/lib/libc/arch/i386/return_one.S
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/arch/ia64/exec_prot_support.c \
    src/tests/lib/libc/arch/ia64/return_one.S
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/arch/m68k/exec_prot_support.c \
    src/tests/lib/libc/arch/m68k/return_one.S
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/arch/mips/exec_prot_support.c \
    src/tests/lib/libc/arch/mips/return_one.S
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/arch/powerpc/exec_prot_support.c \
    src/tests/lib/libc/arch/powerpc/return_one.S
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/arch/powerpc64/exec_prot_support.c \
    src/tests/lib/libc/arch/powerpc64/return_one.S
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/arch/sh3/exec_prot_support.c \
    src/tests/lib/libc/arch/sh3/return_one.S
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/arch/sparc/exec_prot_support.c \
    src/tests/lib/libc/arch/sparc/return_one.S
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/arch/sparc64/exec_prot_support.c \
    src/tests/lib/libc/arch/sparc64/return_one.S
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/arch/vax/exec_prot_support.c \
    src/tests/lib/libc/arch/vax/return_one.S
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/arch/x86_64/exec_prot_support.c \
    src/tests/lib/libc/arch/x86_64/return_one.S
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/common/exec_prot.h
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/sys/Makefile
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_mprotect.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Home | Main Index | Thread Index | Old Index