Skip to content

Commit 6a3981a

Browse files
committed
LoadPin: Return EFAULT on copy_from_user() failures
The copy_from_user() function returns the number of bytes remaining to be copied on a failure. Such failures should return -EFAULT to high levels. Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Fixes: 3f805f8 ("LoadPin: Enable loading from trusted dm-verity devices") Cc: Matthias Kaehlcke <[email protected]> Cc: James Morris <[email protected]> Cc: "Serge E. Hallyn" <[email protected]> Cc: [email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 27603a6 commit 6a3981a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

security/loadpin/loadpin.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,11 @@ static long dm_verity_ioctl(struct file *filp, unsigned int cmd, unsigned long a
356356
{
357357
void __user *uarg = (void __user *)arg;
358358
unsigned int fd;
359-
int rc;
360359

361360
switch (cmd) {
362361
case LOADPIN_IOC_SET_TRUSTED_VERITY_DIGESTS:
363-
rc = copy_from_user(&fd, uarg, sizeof(fd));
364-
if (rc)
365-
return rc;
362+
if (copy_from_user(&fd, uarg, sizeof(fd)))
363+
return -EFAULT;
366364

367365
return read_trusted_verity_root_digests(fd);
368366

0 commit comments

Comments
 (0)