* [PATCH] tty/vt/keyboard: use memdup_user().
@ 2016-05-20 12:23 Muhammad Falak R Wani
2016-05-20 12:27 ` Samuel Thibault
0 siblings, 1 reply; 3+ messages in thread
From: Muhammad Falak R Wani @ 2016-05-20 12:23 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, Samuel Thibault, Dmitry Torokhov, Pavel Machek, linux-kernel
Use memdup_user to duplicate a memory region from user-space to
kernel-space, instead of open coding using kmalloc & copy_from_user.
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
---
drivers/tty/vt/keyboard.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index f973bfc..698ea43 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -1745,16 +1745,10 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm)
return -EINVAL;
if (ct) {
- buf = kmalloc(ct * sizeof(struct kbdiacruc),
- GFP_KERNEL);
- if (buf == NULL)
- return -ENOMEM;
-
- if (copy_from_user(buf, a->kbdiacruc,
- ct * sizeof(struct kbdiacruc))) {
- kfree(buf);
- return -EFAULT;
- }
+ buf = memdup_user(a->kbdiacruc,
+ ct * sizeof(struct kbdiacruc));
+ if (IS_ERR(buf))
+ return PTR_ERR(buf);
}
spin_lock_irqsave(&kbd_event_lock, flags);
if (ct)
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tty/vt/keyboard: use memdup_user().
2016-05-20 12:23 [PATCH] tty/vt/keyboard: use memdup_user() Muhammad Falak R Wani
@ 2016-05-20 12:27 ` Samuel Thibault
2016-07-21 0:54 ` Dmitry Torokhov
0 siblings, 1 reply; 3+ messages in thread
From: Samuel Thibault @ 2016-05-20 12:27 UTC (permalink / raw)
To: Muhammad Falak R Wani
Cc: Greg Kroah-Hartman, Jiri Slaby, Dmitry Torokhov, Pavel Machek,
linux-kernel
Muhammad Falak R Wani, on Fri 20 May 2016 17:53:28 +0530, wrote:
> Use memdup_user to duplicate a memory region from user-space to
> kernel-space, instead of open coding using kmalloc & copy_from_user.
>
> Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> ---
> drivers/tty/vt/keyboard.c | 14 ++++----------
> 1 file changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
> index f973bfc..698ea43 100644
> --- a/drivers/tty/vt/keyboard.c
> +++ b/drivers/tty/vt/keyboard.c
> @@ -1745,16 +1745,10 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm)
> return -EINVAL;
>
> if (ct) {
> - buf = kmalloc(ct * sizeof(struct kbdiacruc),
> - GFP_KERNEL);
> - if (buf == NULL)
> - return -ENOMEM;
> -
> - if (copy_from_user(buf, a->kbdiacruc,
> - ct * sizeof(struct kbdiacruc))) {
> - kfree(buf);
> - return -EFAULT;
> - }
> + buf = memdup_user(a->kbdiacruc,
> + ct * sizeof(struct kbdiacruc));
> + if (IS_ERR(buf))
> + return PTR_ERR(buf);
> }
> spin_lock_irqsave(&kbd_event_lock, flags);
> if (ct)
> --
> 1.9.1
>
--
Samuel
(03:13:14) <j> bon
(03:13:19) <j> il est tard :p
(03:13:25) <g> c'est l'heure de manger
(03:13:38) <j> hm j'ai mangé à 1h moi, j'ai des horaires raisonnables
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tty/vt/keyboard: use memdup_user().
2016-05-20 12:27 ` Samuel Thibault
@ 2016-07-21 0:54 ` Dmitry Torokhov
0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2016-07-21 0:54 UTC (permalink / raw)
To: Samuel Thibault, Muhammad Falak R Wani, Greg Kroah-Hartman,
Jiri Slaby, Pavel Machek, linux-kernel
On Fri, May 20, 2016 at 02:27:05PM +0200, Samuel Thibault wrote:
> Muhammad Falak R Wani, on Fri 20 May 2016 17:53:28 +0530, wrote:
> > Use memdup_user to duplicate a memory region from user-space to
> > kernel-space, instead of open coding using kmalloc & copy_from_user.
> >
> > Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
>
> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Applied, thank you.
>
> > ---
> > drivers/tty/vt/keyboard.c | 14 ++++----------
> > 1 file changed, 4 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
> > index f973bfc..698ea43 100644
> > --- a/drivers/tty/vt/keyboard.c
> > +++ b/drivers/tty/vt/keyboard.c
> > @@ -1745,16 +1745,10 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm)
> > return -EINVAL;
> >
> > if (ct) {
> > - buf = kmalloc(ct * sizeof(struct kbdiacruc),
> > - GFP_KERNEL);
> > - if (buf == NULL)
> > - return -ENOMEM;
> > -
> > - if (copy_from_user(buf, a->kbdiacruc,
> > - ct * sizeof(struct kbdiacruc))) {
> > - kfree(buf);
> > - return -EFAULT;
> > - }
> > + buf = memdup_user(a->kbdiacruc,
> > + ct * sizeof(struct kbdiacruc));
> > + if (IS_ERR(buf))
> > + return PTR_ERR(buf);
> > }
> > spin_lock_irqsave(&kbd_event_lock, flags);
> > if (ct)
> > --
> > 1.9.1
> >
>
> --
> Samuel
> (03:13:14) <j> bon
> (03:13:19) <j> il est tard :p
> (03:13:25) <g> c'est l'heure de manger
> (03:13:38) <j> hm j'ai mangé à 1h moi, j'ai des horaires raisonnables
--
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-07-21 0:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-20 12:23 [PATCH] tty/vt/keyboard: use memdup_user() Muhammad Falak R Wani
2016-05-20 12:27 ` Samuel Thibault
2016-07-21 0:54 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).