public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paulo Marques <pmarques@grupopie.com>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
	David Miller <davem@davemloft.net>,
	Andrew Morton <akpm@linux-foundation.org>,
	Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 1/6] POWERPC: use KSYM_NAME_LEN
Date: Wed, 23 Jan 2008 18:26:28 +0000	[thread overview]
Message-ID: <479786D4.9080601@grupopie.com> (raw)
In-Reply-To: <20080123173832.GA12877@cvg>

Cyrill Gorcunov wrote:
> Use KSYM_NAME_LEN instead of numeric value.

The patch series looks like a nice cleanup, except for a few things in 
this patch.

> Actually because of too small 'tmp' there is
> a potential buffer overflow.

I don't think there is. "tmp" is not being passed to kallsyms to be 
filled with a symbol name, but it's being used to hold a name written by 
the user to lookup an address.

If the powerpc/xmon people feel that 63 characters is enough to hold a 
symbol name, it's their problem, but there is no buffer overflow.

> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
> 
> Index: linux-2.6.git/arch/powerpc/xmon/xmon.c
> ===================================================================
> --- linux-2.6.git.orig/arch/powerpc/xmon/xmon.c	2008-01-23 19:04:42.000000000 +0300
> +++ linux-2.6.git/arch/powerpc/xmon/xmon.c	2008-01-23 19:12:45.000000000 +0300
> @@ -69,7 +69,7 @@ static unsigned long ndump = 64;
>  static unsigned long nidump = 16;
>  static unsigned long ncsum = 4096;
>  static int termch;
> -static char tmpstr[128];
> +static char tmpstr[KSYM_NAME_LEN];

This one seems ok, since "tmpstr" is used everywhere to hold symbol names.

>  #define JMP_BUF_LEN	23
>  static long bus_error_jmp[JMP_BUF_LEN];
> @@ -2354,7 +2354,7 @@ scanhex(unsigned long *vp)
>  		}
>  	} else if (c == '$') {
>  		int i;
> -		for (i=0; i<63; i++) {
> +		for (i = 0; i < sizeof(tmpstr) / 2; i++) {

This one is completely out of the blue. Why "sizeof(tmpstr) / 2"?

It would make more sense to use "sizeof(tmpstr) - 1", but either way it 
is a change in behavior.

>  			c = inchar();
>  			if (isspace(c)) {
>  				termch = c;
> @@ -2467,7 +2467,7 @@ symbol_lookup(void)
>  {
>  	int type = inchar();
>  	unsigned long addr;
> -	static char tmp[64];
> +	static char tmp[KSYM_NAME_LEN];
>  
>  	switch (type) {
>  	case 'a':
> @@ -2476,7 +2476,7 @@ symbol_lookup(void)
>  		termch = 0;
>  		break;
>  	case 's':
> -		getstring(tmp, 64);
> +		getstring(tmp, sizeof(tmp));
>  		if (setjmp(bus_error_jmp) == 0) {
>  			catch_memory_errors = 1;
>  			sync();

This also introduces a change in behavior. It is still a nice cleanup, 
though. So, if the powerpc people feel they can spare an extra 64 bytes 
of stack here, I guess it's ok.

-- 
Paulo Marques - www.grupopie.com

"As far as we know, our computer has never had an undetected error."
Weisert

  reply	other threads:[~2008-01-23 18:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-23 17:38 [PATCH 1/6] POWERPC: use KSYM_NAME_LEN Cyrill Gorcunov
2008-01-23 18:26 ` Paulo Marques [this message]
2008-01-23 18:43   ` Cyrill Gorcunov
2008-01-23 18:59     ` Paulo Marques
2008-01-23 19:07       ` Cyrill Gorcunov

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=479786D4.9080601@grupopie.com \
    --to=pmarques@grupopie.com \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=gorcunov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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