public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Michael Moese <mmoese@suse.de>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v4 2/3] Add a library wrapper for sigaction()
Date: Mon, 12 Feb 2018 11:03:40 +0100	[thread overview]
Message-ID: <20180212100341.23841-3-mmoese@suse.de> (raw)
In-Reply-To: <20180212100341.23841-1-mmoese@suse.de>

In a multithreaded program, using signal() results in unspecified
behavior. In this case, sigaction() has to be used to install a
signal handler.
Therefore, SAFE_SIGACTION() is added.

Signed-off-by: Michael Moese <mmoese@suse.de>
---
 include/tst_safe_macros.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index 06bff13c7..bf12e0719 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -397,6 +397,26 @@ static inline sighandler_t safe_signal(const char *file, const int lineno,
 #define SAFE_SIGNAL(signum, handler) \
 	safe_signal(__FILE__, __LINE__, (signum), (handler))
 
+
+
+static inline int safe_sigaction(const char *file, const int lineno,
+				 int signum, const struct sigaction *act,
+				 struct sigaction *oldact)
+{
+	int rval;
+
+	rval = sigaction(signum, act, oldact);
+
+	if (rval == -1) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"sigaction(%d, %p, %p) failed", signum, act, oldact);
+	}
+
+	return rval;
+}
+#define SAFE_SIGACTION(signum, act, oldact) \
+	safe_sigaction(__FILE__, __LINE__, (signum), (act), (oldact))
+
 #define SAFE_EXECLP(file, arg, ...) do {                   \
 	execlp((file), (arg), ##__VA_ARGS__);              \
 	tst_brk_(__FILE__, __LINE__, TBROK | TERRNO,       \
-- 
2.13.6


  parent reply	other threads:[~2018-02-12 10:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-12 10:03 [LTP] [PATCH v4 0/3] Add regression test for CVE-2017-17053 Michael Moese
2018-02-12 10:03 ` [LTP] [PATCH v4 1/3] Add library support for /proc/sys/kernel/tainted Michael Moese
2018-02-12 10:03 ` Michael Moese [this message]
2018-02-12 10:03 ` [LTP] [PATCH v4 3/3] Add regression test for CVE-2017-17053 Michael Moese
2018-03-05 16:30   ` Cyril Hrubis
2018-03-06 12:35     ` Michael Moese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180212100341.23841-3-mmoese@suse.de \
    --to=mmoese@suse.de \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox