54 lines
2.2 KiB
Diff
54 lines
2.2 KiB
Diff
BZ#331380 Syscall param timer_create(evp) points to uninitialised byte(s)
|
|
|
|
Only check struct sigevent actually used by the kernel. If SIGEV_THREAD_ID
|
|
is set check sigev_notify_thread_id, otherwise don't.
|
|
|
|
diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c
|
|
index 9dadd84..1a7fa6b 100644
|
|
--- a/coregrind/m_syswrap/syswrap-linux.c
|
|
+++ b/coregrind/m_syswrap/syswrap-linux.c
|
|
@@ -2175,8 +2175,18 @@ PRE(sys_timer_create)
|
|
PRE_REG_READ3(long, "timer_create",
|
|
vki_clockid_t, clockid, struct sigevent *, evp,
|
|
vki_timer_t *, timerid);
|
|
- if (ARG2 != 0)
|
|
- PRE_MEM_READ( "timer_create(evp)", ARG2, sizeof(struct vki_sigevent) );
|
|
+ if (ARG2 != 0) {
|
|
+ struct vki_sigevent *evp = (struct vki_sigevent *) ARG2;
|
|
+ PRE_MEM_READ( "timer_create(evp.sigev_value)", (Addr)&evp->sigev_value,
|
|
+ sizeof(vki_sigval_t) );
|
|
+ PRE_MEM_READ( "timer_create(evp.sigev_signo)", (Addr)&evp->sigev_signo,
|
|
+ sizeof(int) );
|
|
+ PRE_MEM_READ( "timer_create(evp.sigev_notify)", (Addr)&evp->sigev_notify,
|
|
+ sizeof(int) );
|
|
+ if ((evp->sigev_notify & VKI_SIGEV_THREAD_ID) != 0)
|
|
+ PRE_MEM_READ( "timer_create(evp.sigev_notify_thread_id)",
|
|
+ (Addr)&evp->vki_sigev_notify_thread_id, sizeof(int) );
|
|
+ }
|
|
PRE_MEM_WRITE( "timer_create(timerid)", ARG3, sizeof(vki_timer_t) );
|
|
}
|
|
POST(sys_timer_create)
|
|
diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h
|
|
index 14bb8bf..a3c4b3c 100644
|
|
--- a/include/vki/vki-linux.h
|
|
+++ b/include/vki/vki-linux.h
|
|
@@ -544,6 +544,9 @@ typedef struct vki_siginfo {
|
|
#define VKI_SIGEV_PAD_SIZE ((VKI_SIGEV_MAX_SIZE - VKI___ARCH_SIGEV_PREAMBLE_SIZE) \
|
|
/ sizeof(int))
|
|
|
|
+/* This is the flag the kernel handles, userspace/glibc handles SEGEV_THEAD. */
|
|
+#define VKI_SIGEV_THREAD_ID 4
|
|
+
|
|
typedef struct vki_sigevent {
|
|
vki_sigval_t sigev_value;
|
|
int sigev_signo;
|
|
@@ -559,6 +562,8 @@ typedef struct vki_sigevent {
|
|
} _sigev_un;
|
|
} vki_sigevent_t;
|
|
|
|
+#define vki_sigev_notify_thread_id _sigev_un._tid
|
|
+
|
|
//----------------------------------------------------------------------
|
|
// From elsewhere...
|
|
//----------------------------------------------------------------------
|