From: Cristina Opriceana <cristina.opriceana@gmail.com>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: outreachy-kernel@googlegroups.com
Subject: Re: [Outreachy kernel] [PATCH] Staging: rtl8712: Use mem_dup() instead of copy_from_user()
Date: Mon, 23 Mar 2015 13:24:12 +0200 [thread overview]
Message-ID: <1427109852.6799.12.camel@Inspiron> (raw)
In-Reply-To: <alpine.DEB.2.02.1503222101410.2195@localhost6.localdomain6>
On Du, 2015-03-22 at 21:04 +0100, Julia Lawall wrote:
>
> On Sun, 22 Mar 2015, Cristina Opriceana wrote:
>
> > Use mem_dup() instead of its duplicated implementation in order
> > to simplify code. Found with coccinelle.
> >
> > Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com>
> > ---
> > drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 10 +++-------
> > 1 file changed, 3 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
> > index 81f39c3..c39d031 100644
> > --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
> > +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
> > @@ -1912,13 +1912,9 @@ static int r871x_mp_ioctl_hdl(struct net_device *dev,
> > bset = (u8)(p->flags & 0xFFFF);
> > len = p->length;
> > pparmbuf = NULL;
> > - pparmbuf = kmalloc(len, GFP_ATOMIC);
> > - if (pparmbuf == NULL) {
> > - ret = -ENOMEM;
> > - goto _r871x_mp_ioctl_hdl_exit;
> > - }
> > - if (copy_from_user(pparmbuf, p->pointer, len)) {
> > - ret = -EFAULT;
> > + pparmbuf = memdup_user(p->pointer, len);
>
> There is a potential problem with this. memdup_user uses GFP_KERNEL
> (blocking allowed), while the original code used GFP_ATOMIC (blocking not
> allowed). You could check whether any locks can be held on the way to
> this code, which would require GFP_ATOMIC. On the other hand, it may be
> that copy_from_user can only be used when blocking is allowed.
>
> julia
>
As far as i understand, since copy_from_user() may sleep, it cannot be
used while holding a lock. So, the use of GFP_ATOMIC might be useless in
this context.
Either that or copy_from_user shouldn't be used, which is not the case
because the purpose of this function is to receive a command from the
userspace and call its associated handler.
Cristina
next prev parent reply other threads:[~2015-03-23 11:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-22 19:04 [PATCH] Staging: rtl8712: Use mem_dup() instead of copy_from_user() Cristina Opriceana
2015-03-22 20:04 ` [Outreachy kernel] " Julia Lawall
2015-03-23 11:24 ` Cristina Opriceana [this message]
2015-03-23 13:53 ` Julia Lawall
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=1427109852.6799.12.camel@Inspiron \
--to=cristina.opriceana@gmail.com \
--cc=julia.lawall@lip6.fr \
--cc=outreachy-kernel@googlegroups.com \
/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.