Skip to content

Commit

Permalink
LoadPin: Return EFAULT on copy_from_user() failures
Browse files Browse the repository at this point in the history
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 <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 3f805f8 ("LoadPin: Enable loading from trusted dm-verity devices")
Cc: Matthias Kaehlcke <mka@chromium.org>
Cc: James Morris <jmorris@namei.org>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: linux-security-module@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
  • Loading branch information
Kees Cook committed Aug 16, 2022
1 parent 27603a6 commit 6a3981a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions security/loadpin/loadpin.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,11 @@ static long dm_verity_ioctl(struct file *filp, unsigned int cmd, unsigned long a
{
void __user *uarg = (void __user *)arg;
unsigned int fd;
int rc;

switch (cmd) {
case LOADPIN_IOC_SET_TRUSTED_VERITY_DIGESTS:
rc = copy_from_user(&fd, uarg, sizeof(fd));
if (rc)
return rc;
if (copy_from_user(&fd, uarg, sizeof(fd)))
return -EFAULT;

return read_trusted_verity_root_digests(fd);

Expand Down

0 comments on commit 6a3981a

Please sign in to comment.