linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: akpm@linux-foundation.org, linux-kernel@vger.kernel.org
Subject: [PATCH] proc: fix unterminated string
Date: Mon, 17 Sep 2012 11:49:30 +0100	[thread overview]
Message-ID: <20120917104901.29914.81645.stgit@localhost.localdomain> (raw)

From: Alan Cox <alan@linux.intel.com>

oom_score_adj_write doesn't terminate the string as it should. Also fix
sched_autogroup_write and other copy/pastes of the bug.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Cc: Horses <stable@vger.kernel.org>

---

 fs/proc/base.c     |    2 ++
 fs/proc/task_mmu.c |    1 +
 2 files changed, 3 insertions(+)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 21fb230..4d42cf18 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -910,6 +910,7 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
 		err = -EFAULT;
 		goto out;
 	}
+	buffer[count] = '\0';
 
 	err = kstrtoint(strstrip(buffer), 0, &oom_score_adj);
 	if (err)
@@ -1192,6 +1193,7 @@ sched_autogroup_write(struct file *file, const char __user *buf,
 		count = sizeof(buffer) - 1;
 	if (copy_from_user(buffer, buf, count))
 		return -EFAULT;
+	buffer[count] = '\0';
 
 	err = kstrtoint(strstrip(buffer), 0, &nice);
 	if (err < 0)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 79827ce..a1dae68 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -639,6 +639,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
 		count = sizeof(buffer) - 1;
 	if (copy_from_user(buffer, buf, count))
 		return -EFAULT;
+	buffer[count] = '\0';
 	rv = kstrtoint(strstrip(buffer), 10, &type);
 	if (rv < 0)
 		return rv;


             reply	other threads:[~2012-09-17 10:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-17 10:49 Alan Cox [this message]
2012-09-17 13:59 ` [PATCH] proc: fix unterminated string Alan Cox

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=20120917104901.29914.81645.stgit@localhost.localdomain \
    --to=alan@lxorguk.ukuu.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).