From: Tom Hughes Date: Thu, 2 Sep 2010 08:23:35 +0000 (+0000) Subject: Add support for F_DUPFD_CLOEXEC. Fixes #238696. X-Git-Tag: svn/VALGRIND_3_6_0~141 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d139951899acbb52c55d460fc6a528ee686fcc0;p=thirdparty%2Fvalgrind.git Add support for F_DUPFD_CLOEXEC. Fixes #238696. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11316 --- diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index c5fc108f21..09159ac7b2 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -3582,6 +3582,7 @@ PRE(sys_fcntl) // These ones use ARG3 as "arg". case VKI_F_DUPFD: + case VKI_F_DUPFD_CLOEXEC: case VKI_F_SETFD: case VKI_F_SETFL: case VKI_F_SETLEASE: @@ -3634,6 +3635,15 @@ POST(sys_fcntl) ML_(record_fd_open_named)(tid, RES); } } + else if (ARG2 == VKI_F_DUPFD_CLOEXEC) { + if (!ML_(fd_allowed)(RES, "fcntl(DUPFD_CLOEXEC)", tid, True)) { + VG_(close)(RES); + SET_STATUS_Failure( VKI_EMFILE ); + } else { + if (VG_(clo_track_fds)) + ML_(record_fd_open_named)(tid, RES); + } + } } // XXX: wrapper only suitable for 32-bit systems @@ -3654,6 +3664,7 @@ PRE(sys_fcntl64) // These ones use ARG3 as "arg". case VKI_F_DUPFD: + case VKI_F_DUPFD_CLOEXEC: case VKI_F_SETFD: case VKI_F_SETFL: case VKI_F_SETLEASE: @@ -3699,6 +3710,15 @@ POST(sys_fcntl64) ML_(record_fd_open_named)(tid, RES); } } + else if (ARG2 == VKI_F_DUPFD_CLOEXEC) { + if (!ML_(fd_allowed)(RES, "fcntl64(DUPFD_CLOEXEC)", tid, True)) { + VG_(close)(RES); + SET_STATUS_Failure( VKI_EMFILE ); + } else { + if (VG_(clo_track_fds)) + ML_(record_fd_open_named)(tid, RES); + } + } } /* --------------------------------------------------------------------- diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h index beff378b31..6b676e6aeb 100644 --- a/include/vki/vki-linux.h +++ b/include/vki/vki-linux.h @@ -1296,10 +1296,17 @@ struct vki_dirent { // From linux-2.6.8.1/include/linux/fcntl.h //---------------------------------------------------------------------- -#define VKI_F_SETLEASE (VKI_F_LINUX_SPECIFIC_BASE+0) -#define VKI_F_GETLEASE (VKI_F_LINUX_SPECIFIC_BASE+1) +#define VKI_F_SETLEASE (VKI_F_LINUX_SPECIFIC_BASE + 0) +#define VKI_F_GETLEASE (VKI_F_LINUX_SPECIFIC_BASE + 1) -#define VKI_F_NOTIFY (VKI_F_LINUX_SPECIFIC_BASE+2) +#define VKI_F_CANCELLK (VKI_F_LINUX_SPECIFIC_BASE + 5) + +#define VKI_F_DUPFD_CLOEXEC (VKI_F_LINUX_SPECIFIC_BASE + 6) + +#define VKI_F_NOTIFY (VKI_F_LINUX_SPECIFIC_BASE + 2) + +#define VKI_F_SETPIPE_SZ (VKI_F_LINUX_SPECIFIC_BASE + 7) +#define VKI_F_GETPIPE_SZ (VKI_F_LINUX_SPECIFIC_BASE + 8) //---------------------------------------------------------------------- // From linux-2.6.8.1/include/linux/sysctl.h