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 5/5] powerpc/powernv: Check sysparam size before creation
Date: Thu, 24 Apr 2014 16:55:37 +0930 [thread overview]
Message-ID: <1398324337-896-6-git-send-email-joel@jms.id.au> (raw)
In-Reply-To: <1398324337-896-1-git-send-email-joel@jms.id.au>
The size of the sysparam sysfs files is determined from the device tree
at boot. However the buffer is hard coded to 64 bytes. If we encounter a
parameter that is larger than 64, or miss-parse the device tree, the
buffer will overflow when reading or writing to the parameter.
Check it at discovery time, and if the parameter is too large, do not
create a sysfs entry for it.
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
arch/powerpc/platforms/powernv/opal-sysparam.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/powerpc/platforms/powernv/opal-sysparam.c b/arch/powerpc/platforms/powernv/opal-sysparam.c
index 4b3367b..14231a5 100644
--- a/arch/powerpc/platforms/powernv/opal-sysparam.c
+++ b/arch/powerpc/platforms/powernv/opal-sysparam.c
@@ -241,6 +241,12 @@ void __init opal_sys_param_init(void)
/* For each of the parameters, populate the parameter attributes */
for (i = 0; i < count; i++) {
+ if (size[i] > MAX_PARAM_DATA_LEN) {
+ pr_warn("SYSPARAM: Not creating parameter %d as size "
+ "exceeds buffer length\n", i);
+ continue;
+ }
+
sysfs_attr_init(&attr[i].kobj_attr.attr);
attr[i].param_id = id[i];
attr[i].param_size = size[i];
--
1.9.1
prev 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 ` [PATCH 3/5] powerpc/powernv: Check sysfs size before copying Joel Stanley
2014-04-24 7:25 ` [PATCH 4/5] powerpc/powernv: Fix typos in sysparam code Joel Stanley
2014-04-24 7:25 ` Joel Stanley [this message]
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-6-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).