Re: [PATCH 15/17] x86, mpx: do 32-bit-only cmpxchg for 32-bit apps

From: Dave Hansen
Date: Fri Mar 27 2015 - 14:16:58 EST


On 03/27/2015 10:29 AM, Borislav Petkov wrote:
>> > +static int mpx_cmpxchg_bd_entry(struct mm_struct *mm,
>> > + unsigned long *actual_old_val_ptr, long __user *bd_entry_addr,
>> > + unsigned long expected_old_val, unsigned long new_bd_entry)
>> > +{
>> > + int ret;
>> > + /*
>> > + * user_atomic_cmpxchg_inatomic() actually uses sizeof()
>> > + * the pointer thatt we pass to it to figure out how much
>> > + * data to cmpxchg. We have to be careful here not to
>> > + * pass a pointer to a 64-bit data type when we only want
>> > + * a 32-bit copy.
>> > + */
>> > + if (is_64bit_mm(mm)) {
>> > + ret = user_atomic_cmpxchg_inatomic(actual_old_val_ptr,
>> > + bd_entry_addr, expected_old_val, new_bd_entry);
>> > + } else {
>> > + u32 uninitialized_var(actual_old_val_32);
>> > + u32 expected_old_val_32 = expected_old_val;
>> > + u32 new_bd_entry_32 = new_bd_entry;
>> > + u32 __user *bd_entry_32 = (u32 __user *)bd_entry_addr;
>> > + ret = user_atomic_cmpxchg_inatomic(&actual_old_val_32,
>> > + bd_entry_32, expected_old_val_32,
>> > + new_bd_entry_32);
> Hmm, I would've added a user_atomic_cmpxchg_inatomic_size() macro which
> calls __user_atomic_cmpxchg_inatomic().

That would have saved creating 'u32 __user *bd_entry_32' so that we
could implicitly do sizeof(*bd_entry_32). But, what else does it buy us?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/