| From 23f68b4d87e0197e47541f4485a1f84f9886bccf Mon Sep 17 00:00:00 2001 |
| From: WANG Cong <xiyou.wangcong@gmail.com> |
| Date: Thu, 23 Mar 2017 11:03:31 -0700 |
| Subject: [PATCH] kcm: return immediately after copy_from_user() failure |
| |
| commit a80db69e47d764bbcaf2fec54b1f308925e7c490 upstream. |
| |
| There is no reason to continue after a copy_from_user() |
| failure. |
| |
| Fixes: ab7ac4eb9832 ("kcm: Kernel Connection Multiplexor module") |
| Cc: Tom Herbert <tom@herbertland.com> |
| Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> |
| Signed-off-by: David S. Miller <davem@davemloft.net> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c |
| index 285a45a79c7a..990d828fb77b 100644 |
| --- a/net/kcm/kcmsock.c |
| +++ b/net/kcm/kcmsock.c |
| @@ -2005,7 +2005,7 @@ static int kcm_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) |
| struct kcm_attach info; |
| |
| if (copy_from_user(&info, (void __user *)arg, sizeof(info))) |
| - err = -EFAULT; |
| + return -EFAULT; |
| |
| err = kcm_attach_ioctl(sock, &info); |
| |
| @@ -2015,7 +2015,7 @@ static int kcm_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) |
| struct kcm_unattach info; |
| |
| if (copy_from_user(&info, (void __user *)arg, sizeof(info))) |
| - err = -EFAULT; |
| + return -EFAULT; |
| |
| err = kcm_unattach_ioctl(sock, &info); |
| |
| @@ -2026,7 +2026,7 @@ static int kcm_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) |
| struct socket *newsock = NULL; |
| |
| if (copy_from_user(&info, (void __user *)arg, sizeof(info))) |
| - err = -EFAULT; |
| + return -EFAULT; |
| |
| err = kcm_clone(sock, &info, &newsock); |
| |
| -- |
| 2.12.0 |
| |