From: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
To: Chen Gang <gang.chen@asianux.com>
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: Re: [PATCH] PowerPC: kernel: memory access violation when rtas_data_buf contents are more than 1026
Date: Wed, 24 Apr 2013 11:58:04 +0530 [thread overview]
Message-ID: <51777B74.8040204@linux.vnet.ibm.com> (raw)
In-Reply-To: <5175FC36.4060308@asianux.com>
On 04/23/2013 08:42 AM, Chen Gang wrote:
>
> 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.
>
Per parameter length in ibm,get-system-parameter RTAS call is limited to 1026
bytes (1024 bytes of data + 2 bytes length). And 'rtas_data_buf' was set to 0
(first 1026 bytes) before call RTAS call. At the worst if we get junk in RTAS
output length field helps to exit from the while loop. So I don't think we need
this patch.
-Vasant
>
> 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) {
WARNING: multiple messages have this Message-ID (diff)
From: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
To: Chen Gang <gang.chen@asianux.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
"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: Re: [PATCH] PowerPC: kernel: memory access violation when rtas_data_buf contents are more than 1026
Date: Wed, 24 Apr 2013 11:58:04 +0530 [thread overview]
Message-ID: <51777B74.8040204@linux.vnet.ibm.com> (raw)
In-Reply-To: <5175FC36.4060308@asianux.com>
On 04/23/2013 08:42 AM, Chen Gang wrote:
>
> 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.
>
Per parameter length in ibm,get-system-parameter RTAS call is limited to 1026
bytes (1024 bytes of data + 2 bytes length). And 'rtas_data_buf' was set to 0
(first 1026 bytes) before call RTAS call. At the worst if we get junk in RTAS
output length field helps to exit from the while loop. So I don't think we need
this patch.
-Vasant
>
> 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) {
next prev parent reply other threads:[~2013-04-24 6:29 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 ` [PATCH] " Chen Gang
2013-04-23 3:12 ` Chen Gang
2013-04-24 6:28 ` Vasant Hegde [this message]
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=51777B74.8040204@linux.vnet.ibm.com \
--to=hegdevasant@linux.vnet.ibm.com \
--cc=gang.chen@asianux.com \
--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.