qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target-i386: cpu: fix potential buffer overrun in get_register_name_32()
@ 2013-06-03 16:23 Igor Mammedov
  2013-06-04  5:39 ` li guang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Igor Mammedov @ 2013-06-03 16:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: afaerber

spotted by Coverity,
x86_reg_info_32[] is CPU_NB_REGS32 elements long, so accessing
x86_reg_info_32[CPU_NB_REGS32] will be one element off array.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 target-i386/cpu.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 1a501d9..ae8e682 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -221,7 +221,7 @@ X86RegisterInfo32 x86_reg_info_32[CPU_NB_REGS32] = {
 
 const char *get_register_name_32(unsigned int reg)
 {
-    if (reg > CPU_NB_REGS32) {
+    if (reg >= CPU_NB_REGS32) {
         return NULL;
     }
     return x86_reg_info_32[reg].name;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] target-i386: cpu: fix potential buffer overrun in get_register_name_32()
  2013-06-03 16:23 [Qemu-devel] [PATCH] target-i386: cpu: fix potential buffer overrun in get_register_name_32() Igor Mammedov
@ 2013-06-04  5:39 ` li guang
  2013-06-04  5:39 ` Jesse Larrew
  2013-06-04 12:20 ` Andreas Färber
  2 siblings, 0 replies; 4+ messages in thread
From: li guang @ 2013-06-04  5:39 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, afaerber

Reviewed-by: liguang <lig.fnst@cn.fujitsu.com>

在 2013-06-03一的 18:23 +0200,Igor Mammedov写道:
> spotted by Coverity,
> x86_reg_info_32[] is CPU_NB_REGS32 elements long, so accessing
> x86_reg_info_32[CPU_NB_REGS32] will be one element off array.

Yes, it will.

> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  target-i386/cpu.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 1a501d9..ae8e682 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -221,7 +221,7 @@ X86RegisterInfo32 x86_reg_info_32[CPU_NB_REGS32] = {
>  
>  const char *get_register_name_32(unsigned int reg)
>  {
> -    if (reg > CPU_NB_REGS32) {
> +    if (reg >= CPU_NB_REGS32) {
>          return NULL;
>      }
>      return x86_reg_info_32[reg].name;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] target-i386: cpu: fix potential buffer overrun in get_register_name_32()
  2013-06-03 16:23 [Qemu-devel] [PATCH] target-i386: cpu: fix potential buffer overrun in get_register_name_32() Igor Mammedov
  2013-06-04  5:39 ` li guang
@ 2013-06-04  5:39 ` Jesse Larrew
  2013-06-04 12:20 ` Andreas Färber
  2 siblings, 0 replies; 4+ messages in thread
From: Jesse Larrew @ 2013-06-04  5:39 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, afaerber

On 06/03/2013 11:23 AM, Igor Mammedov wrote:
> spotted by Coverity,
> x86_reg_info_32[] is CPU_NB_REGS32 elements long, so accessing
> x86_reg_info_32[CPU_NB_REGS32] will be one element off array.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  target-i386/cpu.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 1a501d9..ae8e682 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -221,7 +221,7 @@ X86RegisterInfo32 x86_reg_info_32[CPU_NB_REGS32] = {
> 
>  const char *get_register_name_32(unsigned int reg)
>  {
> -    if (reg > CPU_NB_REGS32) {
> +    if (reg >= CPU_NB_REGS32) {
>          return NULL;
>      }
>      return x86_reg_info_32[reg].name;
> 

Looks obvious now that it's been spotted. ;)

Reviewed by: Jesse Larrew <jlarrew@linux.vnet.ibm.com>

Jesse Larrew
Software Engineer, KVM Team
IBM Linux Technology Center
Phone: (512) 973-2052 (T/L: 363-2052)
jlarrew@linux.vnet.ibm.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] target-i386: cpu: fix potential buffer overrun in get_register_name_32()
  2013-06-03 16:23 [Qemu-devel] [PATCH] target-i386: cpu: fix potential buffer overrun in get_register_name_32() Igor Mammedov
  2013-06-04  5:39 ` li guang
  2013-06-04  5:39 ` Jesse Larrew
@ 2013-06-04 12:20 ` Andreas Färber
  2 siblings, 0 replies; 4+ messages in thread
From: Andreas Färber @ 2013-06-04 12:20 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, liguang, Jesse Larrew

Am 03.06.2013 18:23, schrieb Igor Mammedov:
> spotted by Coverity,
> x86_reg_info_32[] is CPU_NB_REGS32 elements long, so accessing
> x86_reg_info_32[CPU_NB_REGS32] will be one element off array.
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  target-i386/cpu.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

Thanks, applied to qom-cpu:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-06-04 12:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-03 16:23 [Qemu-devel] [PATCH] target-i386: cpu: fix potential buffer overrun in get_register_name_32() Igor Mammedov
2013-06-04  5:39 ` li guang
2013-06-04  5:39 ` Jesse Larrew
2013-06-04 12:20 ` Andreas Färber

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).