From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
Muhammad Falak R Wani <falakreyaz@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jslaby@suse.com>, Pavel Machek <pavel@ucw.cz>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tty/vt/keyboard: use memdup_user().
Date: Wed, 20 Jul 2016 17:54:04 -0700 [thread overview]
Message-ID: <20160721005404.GE26006@dtor-ws> (raw)
In-Reply-To: <20160520122705.GW10620@var.bordeaux.inria.fr>
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
prev parent reply other threads:[~2016-07-21 0:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160721005404.GE26006@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=falakreyaz@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=samuel.thibault@ens-lyon.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.