lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <474F28EB.20608@oracle.com>
Date:	Thu, 29 Nov 2007 13:02:35 -0800
From:	Randy Dunlap <randy.dunlap@...cle.com>
To:	Joe Perches <joe@...ches.com>
CC:	linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] Reduce stack used by lib/hexdump.c

Joe Perches wrote:
> 200 bytes on stack might be a bit much.
> 
> Size goes up to
>    text    data     bss     dec     hex filename
>    1142       0       0    1142     476 lib/hexdump.o
> Without the WARN_ON
>    1053       0       0    1053     41d lib/hexdump.o
> Before this patch
>    1004       0       0    1004     3ec lib/hexdump.o
> 
> Win some/lose some...
> 
> Signed-off-by: Joe Perches <joe@...ches.com>

Acked-by: Randy Dunlap <randy.dunlap@...cle.com>

> diff --git a/lib/hexdump.c b/lib/hexdump.c
> index 70e23fb..be94934 100644
> --- a/lib/hexdump.c
> +++ b/lib/hexdump.c
> @@ -140,13 +140,20 @@ EXPORT_SYMBOL(hex_dump_to_buffer);
>   * Example output using %DUMP_PREFIX_ADDRESS and 4-byte mode:
>   * ffffffff88089af0: 73727170 77767574 7b7a7978 7f7e7d7c  pqrstuvwxyz{|}~.
>   */
> +
> +#define HEX_LINE_SIZE 200
> +
>  void print_hex_dump(const char *level, const char *prefix_str, int prefix_type,
>  			int rowsize, int groupsize,
>  			const void *buf, size_t len, bool ascii)
>  {
>  	const u8 *ptr = buf;
>  	int i, linelen, remaining = len;
> -	unsigned char linebuf[200];
> +	unsigned char *linebuf;
> +
> +	linebuf = kmalloc(HEX_LINE_SIZE, GFP_KERNEL);
> +	if (!linebuf) {
> +		WARN_ON(1);
> +		return;
> +	}
>  
>  	if (rowsize != 16 && rowsize != 32)
>  		rowsize = 16;
> @@ -155,7 +162,7 @@ void print_hex_dump(const char *level, const char *prefix_str, int prefix_type,
>  		linelen = min(remaining, rowsize);
>  		remaining -= rowsize;
>  		hex_dump_to_buffer(ptr + i, linelen, rowsize, groupsize,
> -				linebuf, sizeof(linebuf), ascii);
> +				linebuf, HEX_LINE_SIZE, ascii);
>  
>  		switch (prefix_type) {
>  		case DUMP_PREFIX_ADDRESS:
> @@ -170,6 +177,7 @@ void print_hex_dump(const char *level, const char *prefix_str, int prefix_type,
>  			break;
>  		}
>  	}
> +	kfree(linebuf);
>  }
>  EXPORT_SYMBOL(print_hex_dump);


-- 
~Randy
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ