linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Joel Stanley <joel@jms.id.au>
To: benh@kernel.crashing.org
Cc: neelegup@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org,
	paulus@samba.org
Subject: [PATCH 3/5] powerpc/powernv: Check sysfs size before copying
Date: Thu, 24 Apr 2014 16:55:35 +0930	[thread overview]
Message-ID: <1398324337-896-4-git-send-email-joel@jms.id.au> (raw)
In-Reply-To: <1398324337-896-1-git-send-email-joel@jms.id.au>

The sysparam code currently uses the userspace supplied number of
bytes when memcpy()ing in to a local 64-byte buffer.

Limit the maximum number of bytes by the size of the buffer.
---
 arch/powerpc/platforms/powernv/opal-sysparam.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/platforms/powernv/opal-sysparam.c b/arch/powerpc/platforms/powernv/opal-sysparam.c
index a363c53..21fdc0a 100644
--- a/arch/powerpc/platforms/powernv/opal-sysparam.c
+++ b/arch/powerpc/platforms/powernv/opal-sysparam.c
@@ -135,6 +135,10 @@ static ssize_t sys_param_store(struct kobject *kobj,
 			kobj_attr);
 	ssize_t ret;
 
+        /* MAX_PARAM_DATA_LEN is sizeof(param_data_buf) */
+        if (count > MAX_PARAM_DATA_LEN)
+                count = MAX_PARAM_DATA_LEN;
+
 	mutex_lock(&opal_sysparam_mutex);
 	memcpy(param_data_buf, buf, count);
 	ret = opal_set_sys_param(attr->param_id, attr->param_size,
-- 
1.9.1

  parent reply	other threads:[~2014-04-24  7:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-24  7:25 [PATCH 0/5] powerpc/powernv: OPAL sysparam sysfs fixes Joel Stanley
2014-04-24  7:25 ` [PATCH 1/5] powerpc/powernv: Fix sysparam sysfs error handling Joel Stanley
2014-04-24  7:25 ` [PATCH 2/5] powerpc/powernv: Use ssize_t for sysparam return values Joel Stanley
2014-04-24  7:25 ` Joel Stanley [this message]
2014-04-24  7:25 ` [PATCH 4/5] powerpc/powernv: Fix typos in sysparam code Joel Stanley
2014-04-24  7:25 ` [PATCH 5/5] powerpc/powernv: Check sysparam size before creation Joel Stanley

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=1398324337-896-4-git-send-email-joel@jms.id.au \
    --to=joel@jms.id.au \
    --cc=benh@kernel.crashing.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=neelegup@linux.vnet.ibm.com \
    --cc=paulus@samba.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).