mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-28 21:07:43 +00:00
zdtm/sigpending/32: check only 12 bytes of _si_fields
The kernel does touch only relevant union member on x86_32. travis-ci: success for zdtm/sigpending/32: check only 12 bytes of _si_fields Cc: Andrei Vagin <avagin@virtuozzo.com> Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
a84e65a63b
commit
1aea2b98d8
@ -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++;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user