From: Chen Gang <gang.chen@asianux.com>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: "sfr@canb.auug.org.au" <sfr@canb.auug.org.au>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"paulus@samba.org" <paulus@samba.org>,
Al Viro <viro@zeniv.linux.org.uk>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Subject: [PATCH] PowerPC: kernel: memory access violation when rtas_data_buf contents are more than 1026
Date: Tue, 23 Apr 2013 11:12:54 +0800 [thread overview]
Message-ID: <5175FC36.4060308@asianux.com> (raw)
In-Reply-To: <5175E85F.1040509@asianux.com>
need set '\0' for 'local_buffer'.
SPLPAR_MAXLENGTH is 1026, RTAS_DATA_BUF_SIZE is 4096. so the contents of
rtas_data_buf may truncated in memcpy.
if contents are really truncated.
the splpar_strlen is more than 1026. the next while loop checking will
not find the end of buffer. that will cause memory access violation.
Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
arch/powerpc/kernel/lparcfg.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/kernel/lparcfg.c b/arch/powerpc/kernel/lparcfg.c
index 801a757..d92f387 100644
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/kernel/lparcfg.c
@@ -299,6 +299,7 @@ static void parse_system_parameter_string(struct seq_file *m)
__pa(rtas_data_buf),
RTAS_DATA_BUF_SIZE);
memcpy(local_buffer, rtas_data_buf, SPLPAR_MAXLENGTH);
+ local_buffer[SPLPAR_MAXLENGTH - 1] = '\0';
spin_unlock(&rtas_data_buf_lock);
if (call_status != 0) {
--
1.7.7.6
WARNING: multiple messages have this Message-ID (diff)
From: Chen Gang <gang.chen@asianux.com>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: "paulus@samba.org" <paulus@samba.org>,
Al Viro <viro@zeniv.linux.org.uk>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Michael Ellerman <michael@ellerman.id.au>,
"sfr@canb.auug.org.au" <sfr@canb.auug.org.au>
Subject: [PATCH] PowerPC: kernel: memory access violation when rtas_data_buf contents are more than 1026
Date: Tue, 23 Apr 2013 11:12:54 +0800 [thread overview]
Message-ID: <5175FC36.4060308@asianux.com> (raw)
In-Reply-To: <5175E85F.1040509@asianux.com>
need set '\0' for 'local_buffer'.
SPLPAR_MAXLENGTH is 1026, RTAS_DATA_BUF_SIZE is 4096. so the contents of
rtas_data_buf may truncated in memcpy.
if contents are really truncated.
the splpar_strlen is more than 1026. the next while loop checking will
not find the end of buffer. that will cause memory access violation.
Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
arch/powerpc/kernel/lparcfg.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/kernel/lparcfg.c b/arch/powerpc/kernel/lparcfg.c
index 801a757..d92f387 100644
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/kernel/lparcfg.c
@@ -299,6 +299,7 @@ static void parse_system_parameter_string(struct seq_file *m)
__pa(rtas_data_buf),
RTAS_DATA_BUF_SIZE);
memcpy(local_buffer, rtas_data_buf, SPLPAR_MAXLENGTH);
+ local_buffer[SPLPAR_MAXLENGTH - 1] = '\0';
spin_unlock(&rtas_data_buf_lock);
if (call_status != 0) {
--
1.7.7.6
next prev parent reply other threads:[~2013-04-23 3:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-18 4:45 [Suggestion] PowerPC: kernel: memory access violation when rtas_data_buf contents are more than 1026 Chen Gang
2013-04-18 4:45 ` Chen Gang
2013-04-23 0:31 ` Benjamin Herrenschmidt
2013-04-23 0:31 ` Benjamin Herrenschmidt
2013-04-23 1:48 ` Chen Gang
2013-04-23 1:48 ` Chen Gang
2013-04-23 3:12 ` Chen Gang [this message]
2013-04-23 3:12 ` [PATCH] " Chen Gang
2013-04-24 6:28 ` Vasant Hegde
2013-04-24 6:28 ` Vasant Hegde
2013-04-24 7:03 ` Chen Gang
2013-04-24 7:03 ` Chen Gang
2013-04-24 7:23 ` Vasant Hegde
2013-04-24 7:23 ` Vasant Hegde
2013-04-24 7:40 ` Chen Gang
2013-04-24 7:40 ` Chen Gang
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=5175FC36.4060308@asianux.com \
--to=gang.chen@asianux.com \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=paulus@samba.org \
--cc=sfr@canb.auug.org.au \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.