From: Heiko Carstens <heiko.carstens@de.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>,
Christian Borntraeger <cborntra@de.ibm.com>
Subject: Running OOM and worse with broken signal handler
Date: Fri, 20 May 2005 08:12:20 +0200 [thread overview]
Message-ID: <20050520061125.GA12656@osiris.boeblingen.de.ibm.com> (raw)
Hi all,
we experienced some interesting behaviour with an out of
memory condition caused by signal handling (on s390x).
The following program ran our system in an OOM situation
and couldn't be killed because the SIGKILL signal couldn't
be delivered.
Necessary for this to happen is that the stack size limit
is set to unlimited.
sig_handler(int sig)
{
asm volatile(".long 0\n");
}
int main (int argc, char **argv)
{
struct sigaction act;
act.sa_handler = &sig_handler;
act.sa_restorer = 0;
act.sa_flags = SA_NOMASK | SA_RESTART;
sigaction(SIGILL, &act, 0);
sigaction(SIGSEGV, &act, 0);
asm volatile(".long 0\n");
}
The instruction in the asm block is suppossed to be an
illegal opcode which enforces a SIGILL.
When executed the following happens:
The illegal instruction causes a SIGILL to be delivered to
the process. Since the signal handler itself contains an
illegal instruction this causes another SIGILL to
be delivered, thus causing the stack to grow unlimited.
When we are finally out of memory the OOM killer selects
our process and sends it a SIGKILL.
Only problem in this scenario is that the SIGKILL never
will be sent to our process simply because there is
always a SIGILL pending too, which will be handled before
the SIGKILL because of its lower number (see next_signal()
in kernel/signal.c).
The only possibly way this signal would be handled would
be that the process is running in userspace while trying
to handle the delivered SIGILL, where it would be interrupted
by an interrupt and upon return to userspace do_signal()
would be called again. This is unfortunately very unlikely
if you are running a nearly timer interrupt free kernel
like we do on s390/s390x.
Since the OOM killer set the TIF_MEMDIE flag for our
process it now is allowed to eat up all the memory left
and our system is more or less dead until you're lucky
and an interrupt hits at the right time and finally
causing the process to be terminated...
Maybe the OOM killer or signal handling would need
a change to fix this?
Thanks,
Heiko
next reply other threads:[~2005-05-20 6:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-20 6:12 Heiko Carstens [this message]
2005-05-20 14:56 ` Kirill Korotaev
2005-05-21 7:34 ` Heiko Carstens
2005-05-23 8:27 ` Kirill Korotaev
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=20050520061125.GA12656@osiris.boeblingen.de.ibm.com \
--to=heiko.carstens@de.ibm.com \
--cc=cborntra@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=schwidefsky@de.ibm.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
Powered by JetHome