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:	24 Sep 2007 21:23:36 +0200
From:	Urs Thuermann <urs@...ogud.escape.de>
To:	Joe Perches <joe@...ches.com>
Cc:	netdev@...r.kernel.org, David Miller <davem@...emloft.net>,
	Patrick McHardy <kaber@...sh.net>,
	Thomas Gleixner <tglx@...utronix.de>,
	Oliver Hartkopp <oliver@...tkopp.net>,
	Oliver Hartkopp <oliver.hartkopp@...kswagen.de>
Subject: Re: [PATCH 2/7] CAN: Add PF_CAN core module

Joe Perches <joe@...ches.com> writes:

> I'd prefer something like this, which removes the unnecessary
> kmalloc/kfree pairs or the equivalent conversions to functions.

I have changed this to a static buffer.  Since this is only in
#ifdef CONFIG_CAN_DEBUG_CORE, it shouldn't hurt.

> #define can_debug_cframe(cf, fmt, arg...) \
> do { \
> 	char buf[20]; \
> 	int dlc = cf->can_dlc; \
> 	if (dlc > 8) \
> 		dlc = 8; \
> 	if (cf->can_id & CAN_EFF_FLAG) \
> 		sprintf(buf, "<%08X> [%X] ", cf->can_id & CAN_EFF_MASK, dlc); \
> 	else \
> 		sprintf(buf, "<%03X> [%X] ", cf->can_id & CAN_SFF_MASK, dlc); \
> 	printk(KERN_DEBUG fmt, ##arg); \
> 	print_hex_dump(buf, DUMP_PREFIX_NONE, cf->data, dlc); \
> } while (0)

The line isn't printed atomically, i.e. it could happen that something
is printed between the fmt+args and the hexdump, i.e inbetween the
line.

> and
> 
> #define can_debug_skb(skb) \
> do { \
> 	pr_debug("skbuff at %p, dev: %d, proto: %04x\n", \
> 		 skb, skb->dev ? skb->dev->ifindex : -1, \
> 		 ntohs(skb->protocol)); \
> 	pr_debug("users: %d, dataref: %d, nr_frags: %d, " \
> 		 "h,d,t,e,l: %p %+d %+d %+d, %d\n", \
> 		 atomic_read(&skb->users), \
> 		 atomic_read(&(skb_shinfo(skb)->dataref)), \
> 		 skb_shinfo(skb)->nr_frags, \
> 		 skb->head, skb->data - skb->head, \
> 		 skb->tail - skb->head, skb->end - skb->head, skb->len); \
> 	print_hex_dump(KERN_DEBUG, "skb_head: ", DUMP_PREFIX_NONE, \
> 		       16, 1, skb->head, skb->end - skb->head); \ 
> } while (0)

Here, the consecutive lines aren't printed atomically.

I think sprintf() to a buffer first and the do one printk() is
better.  But I will use hex_dump_to_buffer().


urs
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ