From: Alex Barcelo <abarcelo@ac.upc.edu>
To: qemu-devel@nongnu.org
Cc: Riku Voipio <riku.voipio@iki.fi>, Alex Barcelo <abarcelo@ac.upc.edu>
Subject: [Qemu-devel] [PATCHv3 2/2] signal: sigsegv protection on do_sigprocmask
Date: Sat, 20 Oct 2012 16:15:57 +0200 [thread overview]
Message-ID: <1350742557-9717-3-git-send-email-abarcelo@ac.upc.edu> (raw)
In-Reply-To: <1350742557-9717-1-git-send-email-abarcelo@ac.upc.edu>
Create a safe wrapper by protecting the signal mask.
Instead of doing a simple passthrough of the sigprocmask, the wrapper
manipulates the signal mask in a safe way for the qemu internal. This
is done by avoiding SIGSEGV bit mask manipulation from the guest.
We also return the same bit on the SIGSEGV. This is not required for
most applications, but if the application checks it, then it will see
that somethings fishy about it (and, in fact, maybe it should). If we
do not want the guest to be aware of those manipulations, then it should
be implemented in another way, but this seems quite clean and consistent.
The wrapper can be improved to add more features for better signal
managing, but this seems enough for "simple" self-modifying code.
Signed-off-by: Alex Barcelo <abarcelo@ac.upc.edu>
---
linux-user/signal.c | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 172de9a..b430ab0 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -5489,7 +5489,24 @@ long do_rt_sigreturn(CPUArchState *env)
*/
int do_sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
{
- return sigprocmask(how, set, oldset);
+ int ret;
+ sigset_t val;
+ sigset_t *temp;
+ if (set) {
+ val = *set;
+ temp = &val;
+ sigdelset(temp, SIGSEGV);
+ } else {
+ temp = NULL;
+ }
+ ret = sigprocmask(how, temp, oldset);
+
+ /* Force set state of SIGSEGV, may be best for some apps, maybe not so good
+ * This is not required for qemu to work */
+ if (oldset) {
+ sigaddset(oldset, SIGSEGV);
+ }
+ return ret;
}
void process_pending_signals(CPUArchState *cpu_env)
--
1.7.5.4
next prev parent reply other threads:[~2012-10-20 14:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-20 14:15 [Qemu-devel] [PATCHv3 0/2] Preparing safe sigprocmask wrapper on qemu-user Alex Barcelo
2012-10-20 14:15 ` [Qemu-devel] [PATCHv3 1/2] signal: added a wrapper for sigprocmask function Alex Barcelo
2012-10-20 14:15 ` Alex Barcelo [this message]
2012-11-19 19:01 ` [Qemu-devel] [PATCHv3 0/2] Preparing safe sigprocmask wrapper on qemu-user Alex Barcelo
2013-01-14 14:34 ` Alex Barcelo
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=1350742557-9717-3-git-send-email-abarcelo@ac.upc.edu \
--to=abarcelo@ac.upc.edu \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
/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;
as well as URLs for NNTP newsgroup(s).