On 03/03/2017, 01:27 PM, Jiri Slaby wrote: > Decoding of encoded_op is a bit unreadable. It contains shifts to the > left and to the right by some constants. Make it clearly visible what > part of the bit mask is taken and shift the values only to the right > appropriatelly. > > Signed-off-by: Jiri Slaby <jsl...@suse.cz> > --- > kernel/futex.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/kernel/futex.c b/kernel/futex.c > index c09424406560..5834df248f09 100644 > --- a/kernel/futex.c > +++ b/kernel/futex.c > @@ -1459,10 +1459,10 @@ futex_wake(u32 __user *uaddr, unsigned int flags, int > nr_wake, u32 bitset) > > static int futex_atomic_op_inuser(unsigned int encoded_op, u32 __user *uaddr) > { > - int op = (encoded_op >> 28) & 7; > - int cmp = (encoded_op >> 24) & 15; > - int oparg = (encoded_op << 8) >> 20; > - int cmparg = (encoded_op << 20) >> 20; > + int op = (encoded_op & 0x70000000) >> 28; > + int cmp = (encoded_op & 0x0f000000) >> 24; > + int oparg = (encoded_op & 0x00fff000) >> 12; > + int cmparg = encoded_op & 0x00000fff;
And it turned out that this one is actually invalid as it doesn't preserve signedness on oparg and cmdarg. So please avoid applying this one. thanks, -- js suse labs