Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1467304
| From | "Michael S. Tsirkin" <mst@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/2] tun: Use memdup_user() rather than duplicating its implementation |
| Date | 2016-08-22 03:50 +0200 |
| Message-ID | <s8Mxb-84P-13@gated-at.bofh.it> (permalink) |
| References | <qEuGl-43C-5@gated-at.bofh.it> <s88T7-8qJ-1@gated-at.bofh.it> <s892N-8tA-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Sat, Aug 20, 2016 at 09:34:56AM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 20 Aug 2016 08:54:15 +0200
>
> Reuse existing functionality from memdup_user() instead of keeping
> duplicate source code.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> drivers/net/tun.c | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 9c8b5bc..a1aeccb 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -731,14 +731,9 @@ static int update_filter(struct tap_filter *filter, void __user *arg)
> }
>
> alen = ETH_ALEN * uf.count;
> - addr = kmalloc(alen, GFP_KERNEL);
> - if (!addr)
> - return -ENOMEM;
> -
> - if (copy_from_user(addr, arg + sizeof(uf), alen)) {
> - err = -EFAULT;
> - goto done;
> - }
> + addr = memdup_user(arg + sizeof(uf), alen);
> + if (IS_ERR(addr))
> + return PTR_ERR(addr);
>
> /* The filter is updated without holding any locks. Which is
> * perfectly safe. We disable it first and in the worst
> --
> 2.9.3
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/2] tun: Fine-tuning for update_filter() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-20 09:30 +0200
[PATCH 2/2] tun: Rename a jump label in update_filter() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-20 09:40 +0200
Re: [PATCH 2/2] tun: Rename a jump label in update_filter() "Michael S. Tsirkin" <mst@redhat.com> - 2016-08-22 03:50 +0200
Re: [PATCH 2/2] tun: Rename a jump label in update_filter() Mike Rapoport <rppt@linux.vnet.ibm.com> - 2016-08-22 07:30 +0200
[PATCH 1/2] tun: Use memdup_user() rather than duplicating its implementation SF Markus Elfring <elfring@users.sourceforge.net> - 2016-08-20 09:40 +0200
Re: [PATCH 1/2] tun: Use memdup_user() rather than duplicating its implementation Shmulik Ladkani <shmulik.ladkani@gmail.com> - 2016-08-20 13:50 +0200
Re: [PATCH 1/2] tun: Use memdup_user() rather than duplicating its implementation "Michael S. Tsirkin" <mst@redhat.com> - 2016-08-22 03:50 +0200
Re: [PATCH 0/2] tun: Fine-tuning for update_filter() David Miller <davem@davemloft.net> - 2016-08-21 04:20 +0200
csiph-web