[CRIU] [PATCH] zdtm/sigpending/32: check only 12 bytes of _si_fields
Dmitry Safonov
dsafonov at virtuozzo.com
Fri Jan 20 07:49:00 PST 2017
The kernel does touch only relevant union member on x86_32.
Cc: Andrei Vagin <avagin at virtuozzo.com>
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
test/zdtm/static/sigpending.c | 28 +++++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/test/zdtm/static/sigpending.c b/test/zdtm/static/sigpending.c
index d1dbd251daed..70c2580a1115 100644
--- a/test/zdtm/static/sigpending.c
+++ b/test/zdtm/static/sigpending.c
@@ -29,6 +29,26 @@ static int thread_nr;
# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
+#ifdef __i386__
+/*
+ * On x86_32 kernel puts only relevant union member when signal arrives,
+ * leaving _si_fields to be filled with junk from stack. Check only
+ * first 12 bytes:
+ * // POSIX.1b signals.
+ * struct
+ * {
+ * __pid_t si_pid; // Sending process ID.
+ * __uid_t si_uid; // Real user ID of sending process.
+ * sigval_t si_sigval; // Signal value.
+ * } _rt;
+ * Look at __copy_siginfo_to_user32() for more information.
+ */
+# define _si_fields_sz 12
+#else
+# define _si_fields_sz (sizeof(siginfo_t) - offsetof(siginfo_t, _sifields))
+#endif
+#define siginfo_filled (offsetof(siginfo_t, _sifields) + _si_fields_sz)
+
static pthread_mutex_t exit_lock;
static pthread_mutex_t init_lock;
@@ -71,13 +91,12 @@ static void sig_handler(int signal, siginfo_t *info, void *data)
}
crc = ~0;
- if (datachk((uint8_t *) &info->_sifields,
- sizeof(siginfo_t) - offsetof(siginfo_t, _sifields), &crc)) {
+ if (datachk((uint8_t *) &info->_sifields, _si_fields_sz, &crc)) {
fail("CRC mismatch\n");
return;
}
- if (memcmp(info, src, sizeof(siginfo_t))) {
+ if (memcmp(info, src, siginfo_filled)) {
fail("Source and received info are differ\n");
return;
}
@@ -154,8 +173,7 @@ int send_siginfo(int signo, pid_t pid, pid_t tid, int group, siginfo_t *info)
info->si_code = si_code;
si_code--;
info->si_signo = signo;
- datagen((uint8_t *) &info->_sifields,
- sizeof(siginfo_t) - offsetof(siginfo_t, _sifields), &crc);
+ datagen((uint8_t *) &info->_sifields, _si_fields_sz, &crc);
sent_sigs++;
--
2.11.0
More information about the CRIU
mailing list