From: Matt Fleming <matt@console-pimps.org>
To: "Håvard Skinnemoen" <hskinnemoen@gmail.com>
Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>,
linux-kernel <linux-kernel@vger.kernel.org>,
Oleg Nesterov <oleg@redhat.com>
Subject: Re: avr32: handle_signal() bug?
Date: Mon, 08 Aug 2011 11:25:49 +0100 [thread overview]
Message-ID: <1312799149.10579.109.camel@mfleming-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <CAF8ieYU2ThME1Q3u6xOp0sVOh-dPep-874TDY-=-q9E3OiSQAg@mail.gmail.com>
On Sun, 2011-08-07 at 10:20 -0700, Håvard Skinnemoen wrote:
> Hi Matt,
>
> On Wed, Aug 3, 2011 at 2:04 AM, Matt Fleming <matt@console-pimps.org> wrote:
> > That doesn't look correct to me. Now, if we were unsuccessful in setting
> > up a signal frame, say, ret == -EFAULT, do we really want to block the
> > signal or any of the signals in the handler mask?
>
> I'm assuming this is a rhetorical question :-)
Sort of. I phrased it as a question so that someone could point out
whether my analysis was correct or not ;-)
> Looks good to me. I'm not sure how to test it though...I can try to
> build a kernel, run it on my board and see if it explodes, but I
> suspect this bug is a lot more subtle than that.
I suspect the best test would be one that makes use of SA_NODEFER.
Something like this,
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
void handler(int signum)
{
sigset_t mask;
sigprocmask(SIG_BLOCK, NULL, &mask);
printf("SIGUSR2: %s\n",
sigismember(&mask, SIGUSR2) ? "blocked" : "not blocked");
printf("SIGTERM: %s\n",
sigismember(&mask, SIGTERM) ? "blocked" : "not blocked");
}
int main(int argc, char **argv)
{
pid_t pid;
pid = fork();
if (pid == -1) {
perror("fork");
exit(EXIT_FAILURE);
} else if (!pid) {
struct sigaction act;
memset(&act, 0, sizeof(act));
act.sa_handler = handler;
act.sa_flags = SA_NODEFER;
sigaddset(&act.sa_mask, SIGUSR2);
sigaddset(&act.sa_mask, SIGTERM);
sigaction(SIGUSR1, &act, NULL);
pause();
} else {
int status;
sleep(3);
kill(pid, SIGUSR1);
waitpid(pid, &status, 0);
}
return 0;
}
Without the patch applied I would expect this testcase to run the signal
handler without SIGUSR2 or SIGTERM blocked. With the patch I'd hope you
would see the following,
[matt@mfleming-mobl1 signal-tests]$ ./nodefer
SIGUSR2: blocked
SIGTERM: blocked
--
Matt Fleming, Intel Open Source Technology Center
next prev parent reply other threads:[~2011-08-08 10:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-03 9:04 Matt Fleming
2011-08-03 13:08 ` Oleg Nesterov
2011-08-03 13:39 ` [PATCH] avr32: use set_current_blocked() in handle_signal/sys_rt_sigreturn Oleg Nesterov
2011-08-03 13:56 ` Matt Fleming
2011-08-07 17:20 ` avr32: handle_signal() bug? Håvard Skinnemoen
2011-08-08 10:25 ` Matt Fleming [this message]
2011-08-16 5:55 ` Håvard Skinnemoen
2011-08-16 9:57 ` Matt Fleming
2011-08-16 15:39 ` Oleg Nesterov
2011-08-17 5:14 ` Håvard Skinnemoen
2011-08-17 9:48 ` Matt Fleming
2011-08-17 4:32 ` Håvard Skinnemoen
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=1312799149.10579.109.camel@mfleming-mobl1.ger.corp.intel.com \
--to=matt@console-pimps.org \
--cc=egtvedt@samfundet.no \
--cc=hskinnemoen@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
/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
all inboxes | Powered by JetHome®