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:	Mon, 5 Mar 2007 11:30:49 -0500
From:	Kyle Moffett <mrmacman_g4@....com>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Mathieu Desnoyers <compudj@...gle.com>,
	Haavard Skinnemoen <hskinnemoen@...el.com>,
	linux-kernel@...r.kernel.org
Subject: Re: Thread flags modified without set_thread_flag() (non atomically)

On Mar 01, 2007, at 17:41:38, Andrew Morton wrote:
> Well, it's unusual for code to want to test multiple bitflags in  
> the same operation.  Perhaps thread_info.flags is unusual in that  
> regard.
>
> But one can still do
>
> 	if (foo->flags & (1<<bar)|(1<<zot))
>
> Which can get to be a pain if it happens in a lot of places.  But  
> if it only happens in a few places, this seems a reasonable price  
> to pay, given the safety gains.
>
> Plus I'm _forever_ having to go into the header file to remember  
> whether REQ_RW is the bitmask or the bit offset.

Hey Andrew, I think you just fell victim to an order-of-operations  
bug;  '&' has a higher priority than '|' does, so:

   if ( (foo->flags & (1<<bar)) | (1<<zot))

Or:

   if ( dynamic_value | always_true_constant )

And as such this if statement is always true.  You'd need an extra  
pair of parentheses to make it correct.

Cheers,
Kyle Moffett

-
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