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: <20070928013822.28348.qmail@science.horizon.com>
Date:	27 Sep 2007 21:38:22 -0400
From:	linux@...izon.com
To:	vegard.nossum@...il.com
Cc:	linux@...izon.com, linux-kernel@...r.kernel.org
Subject: Re: [RFC] New kernel-message logging API (take 2)

> Example: {
>	struct kprint_block out;
>	kprint_block_init(&out, KPRINT_DEBUG);
>	kprint_block(&out, "Stack trace:");
>
>	while(unwind_stack()) {
>		kprint_block(&out, "%p %s", address, symbol);
>	}
>	kprint_block_flush(&out);
> }

Assuming that kprint_block_flush() is a combination of
kprint_block_printit() and kprint_block_abort(), you
coulld make a macro wrapper for this to preclude leaks:

#define KPRINT_BLOCK(block, level, code) \
do { \
	struct kprint_block block; \
	kprint_block_init(&block, KPRINT_##level); \
	do { \
		code ; \
		kprint_block_printit(&block); \
	while (0); \
	kprint_block_abort(&block); \
} while(0)

The inner do { } while(0) region is so you can abort with "break".

(Or you can split it into KPRINT_BEGIN() and KPRINT_END() macros,
if that works out to be cleaner.)
-
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