signal: fix decoding of struct old_sigaction on some architectures

On alpha, struct old_sigaction.sa_flags has a 32-bit type.

On mips, only first word of old_sigaction.sa_mask is read.

On all architectures except alpha and mips that have old sigaction
syscall, struct old_sigaction has sa_restorer field that has to be
decoded.

* signal.c (struct old_sigaction) [ALPHA]: Change sa_flags type
to unsigned int, add ATTRIBUTE_PACKED.
[MIPS]: Dhrink sa_mask array to 1 element.
[!ALPHA && !MIPS]: Define sa_restorer field unconditionally.
(struct old_sigaction32): Likewise.
(decode_old_sigaction) [!current_wordsize]: Initialize sa_restorer field
from old_sigaction32.sa_restorer unconditionally.
[!ALPHA && !MIPS]: Print old_sigaction.sa_restorer if SA_RESTORER flag
is set.
* NEWS: Mention this change.
This commit is contained in:
Дмитрий Левин 2017-05-28 17:13:29 +00:00
parent a560ac718e
commit 337d3a10ce
2 changed files with 14 additions and 16 deletions

1
NEWS
View File

@ -7,6 +7,7 @@ Noteworthy changes in release ?.?? (????-??-??)
* strace no longer resets SIGCHLD handler in tracees to the default action.
* When traced command is terminated by a blocked signal, strace unblocks
that signal to ensure its own termination with the same signal.
* Fixed corner cases in decoding of old sigaction syscall.
Noteworthy changes in release 4.17 (2017-05-24)
===============================================

View File

@ -300,29 +300,32 @@ SYS_FUNC(ssetmask)
struct old_sigaction {
/* sa_handler may be a libc #define, need to use other name: */
#ifdef MIPS
#if defined MIPS
unsigned int sa_flags;
unsigned long sa_handler__;
/* Kernel treats sa_mask as an array of longs. */
unsigned long sa_mask[NSIG / sizeof(long)];
unsigned long sa_mask;
#elif defined ALPHA
unsigned long sa_handler__;
unsigned long sa_mask;
unsigned int sa_flags;
#else
unsigned long sa_handler__;
unsigned long sa_mask;
unsigned long sa_flags;
#endif /* !MIPS */
#if HAVE_SA_RESTORER
unsigned long sa_restorer;
#endif
};
}
#ifdef ALPHA
ATTRIBUTE_PACKED
#endif
;
struct old_sigaction32 {
/* sa_handler may be a libc #define, need to use other name: */
uint32_t sa_handler__;
uint32_t sa_mask;
uint32_t sa_flags;
#if HAVE_SA_RESTORER
uint32_t sa_restorer;
#endif
};
static void
@ -340,9 +343,7 @@ decode_old_sigaction(struct tcb *const tcp, const kernel_ulong_t addr)
memset(&sa, 0, sizeof(sa));
sa.sa_handler__ = sa32.sa_handler__;
sa.sa_flags = sa32.sa_flags;
#if HAVE_SA_RESTORER && defined SA_RESTORER
sa.sa_restorer = sa32.sa_restorer;
#endif
sa.sa_mask = sa32.sa_mask;
} else
#endif
@ -352,15 +353,11 @@ decode_old_sigaction(struct tcb *const tcp, const kernel_ulong_t addr)
tprints("{sa_handler=");
print_sa_handler(sa.sa_handler__);
tprints(", sa_mask=");
#ifdef MIPS
tprintsigmask_addr("", sa.sa_mask);
#else
tprintsigmask_val("", sa.sa_mask);
#endif
tprints(", sa_flags=");
printflags(sigact_flags, sa.sa_flags, "SA_???");
#if HAVE_SA_RESTORER && defined SA_RESTORER
if (sa.sa_flags & SA_RESTORER) {
#if !(defined ALPHA || defined MIPS)
if (sa.sa_flags & 0x04000000U) {
tprints(", sa_restorer=");
printaddr(sa.sa_restorer);
}