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, 28 Sep 2007 13:46:00 +0200
From:	"Vegard Nossum" <vegard.nossum@...il.com>
To:	"Geert Uytterhoeven" <geert@...ux-m68k.org>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	"Kyle Moffett" <mrmacman_g4@....com>,
	"Michael Holzheu" <holzheu@...ux.vnet.ibm.com>,
	"Joe Perches" <joe@...ches.com>, "Rob Landley" <rob@...dley.net>,
	"Dick Streefland" <dick.streefland@...ium.nl>,
	"Jesse Barnes" <jesse.barnes@...el.com>,
	"Arnd Bergmann" <arnd@...db.de>,
	"Jan Engelhardt" <jengelh@...putergmbh.de>,
	"Emil Medve" <Emilian.Medve@...escale.com>,
	"Stephen Hemminger" <shemminger@...ux-foundation.org>,
	"linux@...izon.com" <linux@...izon.com>
Subject: Re: [RFC] New kernel-message logging API (take 2)

> If-blocks spanning macros are really dangerous!
>
> E.g. an Ethernet driver may want to do:
>
>         kprint_block(&block, "MAC ");
>         for (i = 0; i < 6; i++) {
>                 card->mac[i] = obtain_mac_byte_from_hw(i);
>                 kprint_block(&block, "%02x", card->mac[i]);
>         }
>
> This looks (and should be) innocent, but the actual MAC addres retrieval
> would never be executed if loglevel <= CONFIG_KPRINT_LOGLEVEL_MAX.

Yup. Okay, so it's definitely NOT an option.

> Can't you store the loglevel in the kprint_block and check it in all
> successive kprint_*() macros? If gcc knows it's constant, it can optimize
> the non-wanted code away. As other fields in struct kprint_block cannot be
> constant (they store internal state), you have to split it like:
>
>     struct kprint_block {
>             int loglevel;
>             struct real_kprint_block real;  /* internal state */
>     }
>
> and pass &block.real() instead of &block to all successive internal functions.
> I haven't tried this, so let's hope gcc is actually smart enough...

It isn't, apparently. Or not with my test, anyway. Either way, it's
probably better not to make those assumptions about or rely too much
on the smartness of the compiler (we don't have *any* guarantees).

The best solution for now is probably to pass the log-level into each
line, as Dick Streefland suggested, though it would lead to a hairier
syntax, or just skip the whole interface for now, as Jan Engelhardt
suggested. Thanks.

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