From: David Engraf <david.engraf@sysgo.com>
To: Andrew Morton <akpm@linux-foundation.org>,
"Daniel M. Weeks" <dan@danweeks.net>,
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
linux-kernel@vger.kernel.org
Subject: [PATCH] add error checks to initramfs
Date: Fri, 18 Jul 2014 10:59:02 +0200 [thread overview]
Message-ID: <53C8E1D6.8020906@sysgo.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 299 bytes --]
On a system with low memory extracting the initramfs may fail. If this
happens the user gets "Failed to execute /init" instead of an initramfs
error.
Check return value of sys_write and call error() when the write was
incomplete or failed.
Signed-off-by: David Engraf <david.engraf@sysgo.com>
[-- Attachment #2: initramfs_error_check.patch --]
[-- Type: text/x-diff, Size: 681 bytes --]
diff --git a/init/initramfs.c b/init/initramfs.c
index a8497fa..64013cc 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -346,7 +346,8 @@ static int __init do_name(void)
static int __init do_copy(void)
{
if (count >= body_len) {
- sys_write(wfd, victim, body_len);
+ if (sys_write(wfd, victim, body_len) != body_len)
+ error("write error");
sys_close(wfd);
do_utime(vcollected, mtime);
kfree(vcollected);
@@ -354,7 +355,8 @@ static int __init do_copy(void)
state = SkipIt;
return 0;
} else {
- sys_write(wfd, victim, count);
+ if (sys_write(wfd, victim, count) != count)
+ error("write error");
body_len -= count;
eat(count);
return 1;
reply other threads:[~2014-07-18 9:07 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=53C8E1D6.8020906@sysgo.com \
--to=david.engraf@sysgo.com \
--cc=akpm@linux-foundation.org \
--cc=dan@danweeks.net \
--cc=linux-kernel@vger.kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
/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