2012-04-20 16:11:29 +04:00
|
|
|
# $NetBSD: Makefile,v 1.22 2012/04/20 12:11:29 jruoho Exp $
|
2011-01-10 07:57:56 +03:00
|
|
|
|
|
|
|
MKMAN= no
|
|
|
|
|
|
|
|
.include <bsd.own.mk>
|
|
|
|
|
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.
2011-07-19 03:16:08 +04:00
|
|
|
.include "../arch/Makefile.exec_prot"
|
|
|
|
|
2011-01-10 07:57:56 +03:00
|
|
|
TESTSDIR= ${TESTSBASE}/lib/libc/sys
|
|
|
|
|
2011-07-07 10:57:53 +04:00
|
|
|
TESTS_C+= t_access
|
|
|
|
TESTS_C+= t_chroot
|
2011-10-15 10:42:16 +04:00
|
|
|
TESTS_C+= t_clock_gettime
|
2011-01-13 05:40:43 +03:00
|
|
|
TESTS_C+= t_clone
|
2011-11-05 22:19:01 +04:00
|
|
|
TESTS_C+= t_connect
|
2011-07-07 10:57:53 +04:00
|
|
|
TESTS_C+= t_dup
|
|
|
|
TESTS_C+= t_fsync
|
2011-07-07 11:06:21 +04:00
|
|
|
TESTS_C+= t_getcontext
|
2011-07-07 10:57:53 +04:00
|
|
|
TESTS_C+= t_getgroups
|
|
|
|
TESTS_C+= t_getitimer
|
|
|
|
TESTS_C+= t_getlogin
|
|
|
|
TESTS_C+= t_getpid
|
|
|
|
TESTS_C+= t_getrusage
|
|
|
|
TESTS_C+= t_getsid
|
|
|
|
TESTS_C+= t_gettimeofday
|
|
|
|
TESTS_C+= t_issetugid
|
2011-11-17 05:14:12 +04:00
|
|
|
TESTS_C+= t_kevent
|
2011-07-07 10:57:53 +04:00
|
|
|
TESTS_C+= t_kill
|
|
|
|
TESTS_C+= t_link
|
2011-11-05 22:19:01 +04:00
|
|
|
TESTS_C+= t_listen
|
2012-03-17 21:23:34 +04:00
|
|
|
TESTS_C+= t_lwp_ctl
|
2011-07-07 10:57:53 +04:00
|
|
|
TESTS_C+= t_mincore
|
2011-10-15 10:26:33 +04:00
|
|
|
TESTS_C+= t_mkdir
|
2011-07-07 10:57:53 +04:00
|
|
|
TESTS_C+= t_mkfifo
|
|
|
|
TESTS_C+= t_mknod
|
2012-04-20 16:11:29 +04:00
|
|
|
TESTS_C+= t_mlock
|
2011-07-07 10:57:53 +04:00
|
|
|
TESTS_C+= t_mmap
|
|
|
|
TESTS_C+= t_mprotect
|
2011-11-05 11:45:40 +04:00
|
|
|
TESTS_C+= t_msgctl
|
|
|
|
TESTS_C+= t_msgget
|
|
|
|
TESTS_C+= t_msgrcv
|
|
|
|
TESTS_C+= t_msgsnd
|
2011-07-07 10:57:53 +04:00
|
|
|
TESTS_C+= t_msync
|
|
|
|
TESTS_C+= t_nanosleep
|
2011-10-15 10:17:02 +04:00
|
|
|
TESTS_C+= t_pipe
|
2011-10-31 19:41:31 +04:00
|
|
|
TESTS_C+= t_pipe2
|
2011-10-15 10:10:26 +04:00
|
|
|
TESTS_C+= t_posix_fadvise
|
2011-07-07 10:57:53 +04:00
|
|
|
TESTS_C+= t_poll
|
|
|
|
TESTS_C+= t_revoke
|
|
|
|
TESTS_C+= t_select
|
|
|
|
TESTS_C+= t_setrlimit
|
|
|
|
TESTS_C+= t_setuid
|
2011-10-15 11:00:48 +04:00
|
|
|
TESTS_C+= t_sigaction
|
2011-01-13 06:09:54 +03:00
|
|
|
TESTS_C+= t_sigqueue
|
2011-11-05 22:19:01 +04:00
|
|
|
TESTS_C+= t_socketpair
|
2011-07-07 10:57:53 +04:00
|
|
|
TESTS_C+= t_stat
|
|
|
|
TESTS_C+= t_timer_create
|
|
|
|
TESTS_C+= t_truncate
|
2011-10-15 10:54:52 +04:00
|
|
|
TESTS_C+= t_ucontext
|
2011-07-07 10:57:53 +04:00
|
|
|
TESTS_C+= t_umask
|
|
|
|
TESTS_C+= t_unlink
|
2011-10-15 10:50:52 +04:00
|
|
|
TESTS_C+= t_write
|
2011-07-07 10:57:53 +04:00
|
|
|
|
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.
2011-07-19 03:16:08 +04:00
|
|
|
SRCS.t_mprotect= t_mprotect.c ${SRCS_EXEC_PROT}
|
|
|
|
|
2011-07-07 10:57:53 +04:00
|
|
|
LDADD.t_getpid+= -lpthread
|
2011-10-15 10:10:26 +04:00
|
|
|
LDADD.t_posix_fadvise+= -lrumpvfs -lrump -lrumpuser -lpthread
|
2011-07-07 10:57:53 +04:00
|
|
|
|
|
|
|
WARNS= 4
|
2011-01-10 07:57:56 +03:00
|
|
|
|
|
|
|
.include <bsd.test.mk>
|
|
|
|
|