From: Max Neklyudov <macscomp@gmail.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Max Neklyudov <macscomp@gmail.com>
Subject: [PATCH 1/1] arm: Fix kernel crash problem in binfmt_flat.c
Date: Thu, 5 Jul 2012 15:59:59 +0400 [thread overview]
Message-ID: <1341489599-29463-1-git-send-email-macscomp@gmail.com> (raw)
If createion of the new process is aborted due to some erros
(lack of memory in my case) kernel will crash because created process
is not terminated properly.
I just sent SIG_KILL in all such points.
Tested on my LM3S1D21 based board
Signed-off-by: Max Neklyudov <macscomp@gmail.com>
---
fs/binfmt_flat.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index 178cb70..79c9838 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -545,6 +545,7 @@ static int load_flat_file(struct linux_binprm * bprm,
textpos = vm_mmap(bprm->file, 0, text_len, PROT_READ|PROT_EXEC,
MAP_PRIVATE|MAP_EXECUTABLE, 0);
if (!textpos || IS_ERR_VALUE(textpos)) {
+ send_sig(SIGKILL, current, 0);
if (!textpos)
textpos = (unsigned long) -ENOMEM;
printk("Unable to mmap process text, errno %d\n", (int)-textpos);
@@ -558,6 +559,7 @@ static int load_flat_file(struct linux_binprm * bprm,
PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 0);
if (realdatastart == 0 || IS_ERR_VALUE(realdatastart)) {
+ send_sig(SIGKILL, current, 0);
if (!realdatastart)
realdatastart = (unsigned long) -ENOMEM;
printk("Unable to allocate RAM for process data, errno %d\n",
@@ -585,6 +587,7 @@ static int load_flat_file(struct linux_binprm * bprm,
data_len + (relocs * sizeof(unsigned long)), &fpos);
}
if (IS_ERR_VALUE(result)) {
+ send_sig(SIGKILL, current, 0);
printk("Unable to read data+bss, errno %d\n", (int)-result);
vm_munmap(textpos, text_len);
vm_munmap(realdatastart, len);
@@ -603,6 +606,7 @@ static int load_flat_file(struct linux_binprm * bprm,
PROT_READ | PROT_EXEC | PROT_WRITE, MAP_PRIVATE, 0);
if (!textpos || IS_ERR_VALUE(textpos)) {
+ send_sig(SIGKILL, current, 0);
if (!textpos)
textpos = (unsigned long) -ENOMEM;
printk("Unable to allocate RAM for process text/data, errno %d\n",
@@ -653,6 +657,7 @@ static int load_flat_file(struct linux_binprm * bprm,
}
}
if (IS_ERR_VALUE(result)) {
+ send_sig(SIGKILL, current, 0);
printk("Unable to read code+data+bss, errno %d\n",(int)-result);
vm_munmap(textpos, text_len + data_len + extra +
MAX_SHARED_LIBS * sizeof(unsigned long));
--
1.7.9.5
reply other threads:[~2012-07-05 12:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1341489599-29463-1-git-send-email-macscomp@gmail.com \
--to=macscomp@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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