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: <1359475998.4196.26.camel@joe-AO722>
Date:	Tue, 29 Jan 2013 08:13:18 -0800
From:	Joe Perches <joe@...ches.com>
To:	Valdis.Kletnieks@...edu
Cc:	cocci@...teme.lip6.fr, Julia Lawall <julia.lawall@...6.fr>,
	Dan Carpenter <dan.carpenter@...cle.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Jiri Slaby <jslaby@...e.cz>,
	Paul Fulghum <paulkf@...rogate.com>,
	David Howells <dhowells@...hat.com>,
	linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: coccinelle and bitmask arithmetic (was: Re: [patch] TTY: synclink,
 small cleanup in dtr_rts())

On Tue, 2013-01-29 at 10:55 -0500, Valdis.Kletnieks@...edu wrote:
> On Sun, 27 Jan 2013 23:19:47 +0300, Dan Carpenter said:
> 
> > Yeah.  I think it would be, but adding bitflags together instead of
> > doing bitwise ORs is very common as well.
> 
> The fact it's common doesn't mean it's good programming practice,
> or even correct.  Consider:
> 
> #define F_FOO 0x01
> #define F_BAR 0x02
> #define F_BAZ 0x04
> 
> unsigned int flags = F_FOO;
> ...
>       flags |= F_BAR;
> 
> Now some time later, another code path does this:
> 
>       flags += F_FOO;
> 
> If it was another |, it would be a no harm no foul class of bug.
> But how long is it going to take you to figure out who set F_BAZ?
> 
> I wonder if there's a way to write a coccinelle patch to find places
> where we do arithmetic operations on bitmasks....

Not so far as I know, but maybe someone on the
cocci lists does. (cc'd)

I could imagine a test for variables that have
uses of both arithmetic and bit operations but
not a discriminator for when one type is
appropriate and the other is not.


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