From: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
To: Wim de With <nauxuron@wimdewith.com>
Cc: gregkh@linuxfoundation.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] staging: gdm72xx: add userspace data struct
Date: Fri, 11 Dec 2015 00:17:20 +0000 [thread overview]
Message-ID: <20151211001720.2332a513@lxorguk.ukuu.org.uk> (raw)
In-Reply-To: <20151210234738.GA28422@boole.wimdewith.com>
On Fri, 11 Dec 2015 00:47:38 +0100
Wim de With <nauxuron@wimdewith.com> wrote:
> On Thu, Dec 10, 2015 at 02:44:45PM +0000, One Thousand Gnomes wrote:
> > (except that you mean sizeof(struct fsm_s) and it doesn't compile at the
> > moment!
>
> Oops, sloppy mistake.
Compile/test/send - even when in a hurry
> > data_s can just be modified to be __user. All uses of it follow that
> > rule.
>
> What do you mean? The data still needs to be copied from user space to kernel
> space, if I'm not mistaken. And not all uses follow that rule, since in both
> gdm_wimax_ioctl_get_data() and gdm_wimax_ioctl_set_data() it is used as both
> the source and destination in the copy_from_user() and copy_to_user() call.
Good point I missed that.
> > All I think you need in this case is
> >
> > struct fsm_s fsm_buf;
> >
> > if (copy_from_user(&fsm_buf, req->data.buf,sizeof(buf))
> > return -EFAULT
> > gdm_update_fsm(&fsm_buf);
>
> Do you mean sizeof(fsm_s)? I realize this would have been far simpler than my
> overkill solution.
Yes either sizeof(struct fsm_s) or sizeof(fsm_buf). The former is often
safer.
> > If you are touching the structs it might be wise to fix the other
> > problems with them notably the use of int. sizes when used are unsigned -
> > and signed sizes are asking for errors. In fact if you look at the
> > existing uses of the size checks they look deeply suspicious the moment
> > anything malicious passes in negative numbers.
>
> I would love to do that, but it is a bit outside the scope of this patch, so I
> would rather safe this for another patch.
Absolutely right - it should be another patch
Alan
next prev parent reply other threads:[~2015-12-11 0:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-10 9:11 [PATCH] " Wim de With
2015-12-10 9:37 ` Dan Carpenter
2015-12-10 9:42 ` Wim de With
2015-12-10 11:34 ` Dan Carpenter
2015-12-10 11:40 ` [PATCH v2] " Wim de With
2015-12-10 14:44 ` One Thousand Gnomes
2015-12-10 23:47 ` Wim de With
2015-12-11 0:17 ` One Thousand Gnomes [this message]
2015-12-11 9:25 ` [PATCH v3] " Wim de With
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=20151211001720.2332a513@lxorguk.ukuu.org.uk \
--to=gnomes@lxorguk.ukuu.org.uk \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nauxuron@wimdewith.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®