fcntl: return -EFAULT if copy_to_user fails

copy_to_user() returns the number of bytes remaining, but we want to
return -EFAULT.
ret = fcntl(fd, F_SETOWN_EX, NULL);
With the original code ret would be 8 here.

V2: Takuya Yoshikawa pointed out a similar issue in f_getown_ex()

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

authored by Dan Carpenter and committed by Al Viro 5b54470d 7d683a09

+5 -2
+5 -2
fs/fcntl.c
··· 274 275 ret = copy_from_user(&owner, owner_p, sizeof(owner)); 276 if (ret) 277 - return ret; 278 279 switch (owner.type) { 280 case F_OWNER_TID: ··· 332 } 333 read_unlock(&filp->f_owner.lock); 334 335 - if (!ret) 336 ret = copy_to_user(owner_p, &owner, sizeof(owner)); 337 return ret; 338 } 339
··· 274 275 ret = copy_from_user(&owner, owner_p, sizeof(owner)); 276 if (ret) 277 + return -EFAULT; 278 279 switch (owner.type) { 280 case F_OWNER_TID: ··· 332 } 333 read_unlock(&filp->f_owner.lock); 334 335 + if (!ret) { 336 ret = copy_to_user(owner_p, &owner, sizeof(owner)); 337 + if (ret) 338 + ret = -EFAULT; 339 + } 340 return ret; 341 } 342