From: Johannes Berg <johannes@sipsolutions.net>
To: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Cc: "John W. Linville" <linville@tuxdriver.com>,
linux-wireless@vger.kernel.org
Subject: Re: [Patch 1/1] wext: fix 32/64 bit alignment issue for 'point' type
Date: Mon, 11 Oct 2010 11:55:47 +0200 [thread overview]
Message-ID: <1286790947.3634.9.camel@jlt3.sipsolutions.net> (raw)
In-Reply-To: <20101011051410.GA3977@gerrit.erg.abdn.ac.uk>
On Mon, 2010-10-11 at 07:14 +0200, Gerrit Renker wrote:
> In the drawings below I have traced with an asterisk where in userspace the data is
> read out - as far as I can see this is correct. The only worrying case is number (3).
> 3) 64-bit compat
> ~~~~~~~~~~~~~~~~
> point_len = IW_EV_COMPAT_POINT_LEN = 8
> iwe->len = event_len = point_len + u.data.length = 8 + u.data.length
> lcp_len = IW_EV_COMPAT_LCP_LEN = 4
> 2nd memcpy: IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN = 12 - 4 = 8
>
> IW_EV_LCP_PK_LEN
> <--------------> *
> +-------+-------+-------+-------+---------------+------- ...-+
> | len | cmd |length | flags | (empty) -> extra ... |
> +-------+-------+-------+-------+---------------+------- ...-+
> 2 2 2 2 4
>
> lcp_len
> <--------------> <-!! OVERLAP !!>
> <--1st memcpy--><------- 2nd memcpy ----------->
> <---- 3rd memcpy ------- ... >
> <--------- point_len ---------->
>
> Here it is as you point out: the second and third memcpy()'s overlap by 4 bytes,
> which would be a problem if the length == 0 and no extra data were to be copied.
This, and the other two cases as well, looks correct.
> --- a/include/net/iw_handler.h
> +++ b/include/net/iw_handler.h
> @@ -548,9 +548,9 @@ iwe_stream_add_point(struct iw_request_info *info, char *stream, char *ends,
> if(likely((stream + event_len) < ends)) {
> iwe->len = event_len;
> memcpy(stream, (char *) iwe, IW_EV_LCP_PK_LEN);
> + /* copy length and flags of iw_point */
> memcpy(stream + lcp_len,
> - ((char *) &iwe->u) + IW_EV_POINT_OFF,
> - IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN);
> + ((char *) &iwe->u) + IW_EV_POINT_OFF, 4);
> memcpy(stream + point_len, extra, iwe->u.data.length);
> stream += event_len;
> }
However, I don't understand this patch. Your original patch would have
fixed this just as well, since after it
IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN
would be
(IW_EV_LCP_PK_LEN + 4) - IW_EV_LCP_PK_LEN == 4
and at the same time fixes the userspace problem, if anyone really wants
to use wext in new applications that don't use iwlib still...
johannes
next prev parent reply other threads:[~2010-10-11 9:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-30 10:25 [Patch 1/1] wext: fix 32/64 bit alignment issue for 'point' type Gerrit Renker
2010-09-30 14:38 ` Johannes Berg
2010-09-30 14:40 ` Johannes Berg
2010-10-01 7:22 ` gerrit
2010-10-01 8:30 ` Johannes Berg
2010-10-11 5:14 ` Gerrit Renker
2010-10-11 9:55 ` Johannes Berg [this message]
2010-10-11 11:56 ` gerrit
2010-10-11 12:00 ` Johannes Berg
2010-10-12 5:07 ` [Patch v2 1/1] wext: fix alignment problem in serializing 'struct iw_point' Gerrit Renker
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=1286790947.3634.9.camel@jlt3.sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=gerrit@erg.abdn.ac.uk \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.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.