Automatically probe for sys/poll.h

Include example of nasty program where strace (by design) gives
incorrect output.
This commit is contained in:
Pavel Machek 2000-02-01 16:12:33 +00:00
parent 5597f898df
commit 245a6ac0e7
4 changed files with 38 additions and 2 deletions

View File

@ -142,7 +142,7 @@ AC_SIG_ATOMIC_T
AC_STAT64
AC_CHECK_LIB(nsl, main)
AC_CHECK_FUNCS(sigaction strerror strsignal pread sys_siglist _sys_siglist getdents mctl putpmsg prctl sendmsg inet_ntop)
AC_CHECK_HEADERS(sys/reg.h sys/filio.h sys/acl.h sys/asynch.h sys/door.h sys/stream.h sys/tiuser.h sys/sysconfig.h asm/sigcontext.h ioctls.h sys/ioctl.h sys/ptrace.h termio.h linux/ptrace.h asm/reg.h linux/in6.h sys/uio.h linux/netlink.h linux/if_packet.h)
AC_CHECK_HEADERS(sys/reg.h sys/filio.h sys/acl.h sys/asynch.h sys/door.h sys/stream.h sys/tiuser.h sys/sysconfig.h asm/sigcontext.h ioctls.h sys/ioctl.h sys/ptrace.h termio.h linux/ptrace.h asm/reg.h linux/in6.h sys/uio.h linux/netlink.h linux/if_packet.h sys/poll.h)
AC_DECL_SYS_ERRLIST
AC_DECL_SYS_SIGLIST
AC_DECL__SYS_SIGLIST

View File

@ -33,7 +33,9 @@
#if defined(HAVE_SYS_STREAM_H) || defined(linux)
#if defined(linux)
#ifdef HAVE_SYS_POLL_H
#include <sys/poll.h>
#endif
#define RS_HIPRI 1
struct strbuf {
@ -253,6 +255,7 @@ struct tcb *tcp;
static struct xlat pollflags[] = {
#ifdef POLLIN
{ POLLIN, "POLLIN" },
{ POLLPRI, "POLLPRI" },
{ POLLOUT, "POLLOUT" },
@ -271,6 +274,7 @@ static struct xlat pollflags[] = {
{ POLLERR, "POLLERR" },
{ POLLHUP, "POLLHUP" },
{ POLLNVAL, "POLLNVAL" },
#endif
{ 0, NULL },
};
@ -280,6 +284,7 @@ struct tcb *tcp;
{
struct pollfd *pollp;
#ifdef HAVE_SYS_POLL_H
if (exiting(tcp)) {
int i;
int nfds = tcp->u_arg[1];
@ -331,6 +336,7 @@ struct tcb *tcp;
tprintf("%ld", tcp->u_arg[2]);
free(pollp);
}
#endif
return 0;
}

View File

@ -2,7 +2,7 @@
# $Id$
#
all: fork sig
all: fork sig skodic
clean distclean:
rm -f fork sig *.o core

30
test/skodic.c Normal file
View File

@ -0,0 +1,30 @@
/* This demonstrates races: kernel may actually open other file then
* you read at strace output. Create /tmp/delme with 10K of zeros and
* 666 mode, then run this under strace. If you see open successfull
* open of /etc/shadow, you know you've seen a race.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
void
main(void)
{
char *c = 0x94000000;
open( "/tmp/delme", O_RDWR );
mmap( c, 4096, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED, 3, 0 );
*c = 0;
if (fork()) {
while(1) {
strcpy( c, "/etc/passwd" );
strcpy( c, "/etc/shadow" );
}
} else
while (1)
open( c, 0 );
}