|
Message-ID: <CA+55aFymwBJ9CxOpnjnNxOxncHLkwfeFQ4Mm=ZhWBZDEAfAd1Q@mail.gmail.com> Date: Mon, 19 Sep 2011 11:32:24 -0700 From: Linus Torvalds <torvalds@...ux-foundation.org> To: Andi Kleen <andi@...stfloor.org> Cc: Balbir Singh <bsingharora@...il.com>, Vasiliy Kulikov <segoon@...nwall.com>, Shailabh Nagar <nagar@...ibm.com>, linux-kernel@...r.kernel.org, security@...nel.org, Eric Paris <eparis@...hat.com>, Stephen Wilson <wilsons@...rt.ca>, KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>, David Rientjes <rientjes@...gle.com>, Andrew Morton <akpm@...ux-foundation.org>, Balbir Singh <balbir@...ux.vnet.ibm.com>, kernel-hardening@...ts.openwall.com Subject: Re: [Security] [PATCH 2/2] taskstats: restrict access to user On Mon, Sep 19, 2011 at 11:29 AM, Andi Kleen <andi@...stfloor.org> wrote: >> >> #define KB 1024 > > Needs to be 1024ULL, because the counters are 64bit. > >> #define MB (1024*KB) >> +#define KB_MASK (~(KB-1)) > > Otherwise you lose the upper 32bits here. No, it's an "int" constant, so it will sign-extend properly when it gets extended to 64 bits. It's "unsigned int" etc that can be dangerous in these kinds of situations. (Of course, in other contexts, sign-extensions of masks is *bad*. So it depends on what you do) Linus
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.