Re: [RFC][PATCH] x86, syscalls: use SYSCALL_DEFINE() macros for sys_modify_ldt()

From: Dave Hansen
Date: Fri Oct 13 2017 - 18:21:54 EST


On 10/13/2017 02:03 PM, Andy Lutomirski wrote:
>>
>> -asmlinkage int sys_modify_ldt(int func, void __user *ptr,
>> - unsigned long bytecount)
>> +SYSCALL_DEFINE3(modify_ldt, int , func , void __user * , ptr ,
>> + unsigned long , bytecount)
> sys_modify_ldt() returns int, which is wrong, and it's visibly wrong
> to 64-bit user code. So I think you need to make sure that the return
> value is cast to int in all cases.

I'm not quite following.

Is there any difference between having something return 'int' and having
it return 'long' but only use the lower 32 bits? The caller is surely
expecting its result in the lower 32 bits, but this should not change that.

Did you just mean that we need to careful to cast the result in
sys_modify_ldt() over to an 'int' before returning it?