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]
Date:	Fri, 14 Jan 2011 10:19:06 -0800
From:	Joe Perches <realty@...ches.com>
To:	Roman Fietze <roman.fietze@...emotive.de>
Cc:	Jason Baron <jbaron@...hat.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Proposal to add dynamic debug feature for
 print_hex_dump

On Fri, 2011-01-14 at 09:43 +0100, Roman Fietze wrote:
> Comments are again welcome.
> Add macros e.g. named pr_<level>_hex_dump calling print_hex_dump with
> the approriate level, with level being emerg, alert, ..., debug. This
> is similiar to the functions starting with "pr_".

Here's a count of the current print_hex_dump uses:

$ grep -rP --include=*.[ch] -oh "print_hex_dump\s*\(\s*KERN_[A-Z]+" * | \
  grep -oh -P "KERN_[A-Z]+" | sort | uniq -c
      1 KERN_ALERT
      2 KERN_CONT
     55 KERN_DEBUG
     44 KERN_ERR
     27 KERN_INFO
     10 KERN_WARNING

A high percentage of these print_hex_dump() uses are
(,,, 16, 1, buf, len, true) so there's some value
in doing this.

Converting all of these uses to this new style will
not be possible.

I suggest simplifying naming to just hex_dump_<level>.

That mirrors the more common prefix_<level> style
(dev_<level>, netdev_<level>, etc) and a few more
uses of a single line of code would be possible.

Adding a hex_dump_printk function to hexdump.c

void hex_dump_printk(const char *level, const char *prefix_str, int prefix_type,
		     const void *buf, size_t len)
{
	print_hex_dump(level, prefix_str, prefix_type, 16, 1,
		       buf, len, true);
}

Removing the print_hex_dump_bytes function and adding

#define print_hex_dump_bytes(prefix, type, buf, len) \
	hex_dump_printk(KERN_DEBUG, prefix, type, buf, len)

Adding macros for the various levels:

#define hex_dump_emerg(prefix, type, buf, len)		\
	hex_dump_printk(KERN_EMERG, prefix, type, len)
#define hex_dump_alert(prefix, type, buf, len)		\
	hex_dump_printk(KERN_ALERT, prefix, type, len)
#define hex_dump_crit(prefix, type, buf, len)		\
	hex_dump_printk(KERN_CRIT, prefix, type, len)
#define hex_dump_err(prefix, type, buf, len)		\
	hex_dump_printk(KERN_ERR, prefix, type, len)
#define hex_dump_warn(prefix, type, buf, len)		\
	hex_dump_printk(KERN_WARNING, prefix, type, len)
#define hex_dump_notice(prefix, type, buf, len)		\
	hex_dump_printk(KERN_NOTICE, prefix, type, len)
#define hex_dump_info(prefix, type, buf, len)		\
	hex_dump_printk(KERN_INFO, prefix, type, len)
#define hex_dump_cont(prefix, type, buf, len)		\
	hex_dump_printk(KERN_CONT, prefix, type, len)

> Use dynamic printk wrapper to support turning pr_debug_hex_dump on and
> off similar to pr_debug using the dynamic debug sysfs control file.

And add and use a #define hex_dump_dbg with
with dynamic_hex_dump_dbg as appropriate.

Lastly, the 20 or so print_hex_dump_bytes
uses could be converted to hex_dump_dbg()
if desired.

cheers, Joe

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