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: <46391730.2080003@oracle.com>
Date:	Wed, 02 May 2007 15:56:48 -0700
From:	Randy Dunlap <randy.dunlap@...cle.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
CC:	lkml <linux-kernel@...r.kernel.org>, jwboyer@...ux.vnet.ibm.com,
	grant.likely@...retlab.ca, jketreno@...ux.intel.com
Subject: Re: [PATCH] lib/hexdump

Andrew Morton wrote:
> On Wed, 2 May 2007 15:35:56 -0700
> Randy Dunlap <randy.dunlap@...cle.com> wrote:
> 
>> From: Randy Dunlap <randy.dunlap@...cle.com>
>>
>> Based on ace_dump_mem() from Grant Likely for the Xilinx 
>> SystemACE CompactFlash interface.
>>
>> Add hex_dumper() to lib/hexdump.c and linux/kernel.h.
>>
>> This patch adds the function 'hex_dumper' which can be used to perform a 
>> hex + ASCII dump of data to syslog, in an easily viewable format, thus
>> providing a common text hex dump format.
>>
>> It does not provide a hexdump_to_buffer() function.
>> if someone needs that, we'll have to add it.
>>
>> Example usage:
>> 	hex_dumper(KERN_DEBUG, data, length);
>>
> 
> Fair enough.  This is the sort of thing one could easily overdesign ;)

The Intel version also returned the number of bytes printed.
and they had a hexdump_to_buffer() for sysfs output.


>>  include/linux/kernel.h |    1 
>>  lib/Makefile           |    2 -
>>  lib/hexdump.c          |   51 +++++++++++++++++++++++++++++++++++++++++++++++++
>>  3 files changed, 53 insertions(+), 1 deletion(-)
>>
>> --- /dev/null
>> +++ linux-2.6.21-git4/lib/hexdump.c
>> @@ -0,0 +1,51 @@

>> +/**
>> + * hex_dumper - print a text hex dump to syslog for a binary blob of data
>> + * @level: kernel log level (e.g. KERN_DEBUG)
>> + * @buf: data blob to dump
>> + * @len: number of bytes in the @buf
>> + *
>> + * Given a buffer of u8 data, hex_dumper() will print a hex + ASCII dump
>> + * to the kernel log at the specified kernel log level.
>> + *
>> + * E.g.:
>> + *	hex_dumper(KERN_DEBUG, frame->data, frame->len);
>> + *
>> + * Prints the offsets of the block of memory, not addresses:
>> + * 0009ab42: 40414243 44454647 48494a4b 4c4d4e4f-@...DEFG HIJKLMNO
> 
> But I suspect it should be printing the addresses, for many callers.
> 
> In which case we'd need a separate arg (base_address or somesuch) so that
> callers who want to show real virtual addresses can pass in `base' and
> callers who want to display relative offsets can pass in 0.

OK, that's one way to do it.  I'll wait a bit for other comments.

> Which implies that the address will need to be printed as a 16-digit number
> on 64-bit kernels.

Yep.


-- 
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
-
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