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:	Sun, 11 Oct 2009 00:06:32 +0100
From:	Alan Cox <alan@...rguk.ukuu.org.uk>
To:	Bernhard Walle <bernhard@...lle.de>
Cc:	akpm@...uxfoundation.org, linux-kernel@...r.kernel.org,
	Bernhard Walle <bernhard@...lle.de>
Subject: Re: [PATCH 3/5] Use vt_get_kmsg_redirect() and
 vt_set_kmsg_redirect()

> -	kmsg_redirect = SUSPEND_CONSOLE;
> +	orig_kmsg = vt_get_kmsg_redirect();
> +	vt_set_kmsg_redirect(SUSPEND_CONSOLE);

Probably better to have a single

	orig_kmsg = vt_kmsg_redirect(new);

because it makes the locking easy and means a third party can't sneak
between those two and break stuff. This has another advantage - the
variable is now function local and the whole pile of stuff you posted
becomes

#if defined(CONFIG_VT_CONSOLE)

extern inline int vt_kmsg_redirect(int new)
{
	static int kmsg_con;

	if (new != -1)
		xchg(new, &kmsg_con);
	else
		new = kmsg_con;
	return new;
}

#else

extern inline int vt_kmsg_redirect(int new)
{
	return 0;
}

#endif


Optionally adding

#define vt_get_kmsg_redirect vt_kmsg_redirect(-1);


One ifdef, clear locking rules, no globals, no file level statics and for
almost all cases it'll compile down to almost nothing.

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