From: Johannes Berg <johannes@sipsolutions.net>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
"John W. Linville" <linville@tuxdriver.com>,
linux-wireless@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] wl3501_cs: min_t() cast truncates high bits
Date: Mon, 26 Sep 2011 10:24:37 +0200 [thread overview]
Message-ID: <1317025477.4117.21.camel@jlt3.sipsolutions.net> (raw)
In-Reply-To: <20110926063040.GE11832@elgon.mountain> (sfid-20110926_101711_920668_B3BB1CCE)
On Mon, 2011-09-26 at 09:30 +0300, Dan Carpenter wrote:
> wrqu->encoding.length comes from the network administrator. It's
> size u16. We want to limit "tocopy" to the smallest value of either
> "len_keys", "wrqu->encoding.length" or 100. But because .length
> gets cast from u16 to u8 we might use a random, smaller value than
> the was desired. It's probably not very serious, but we may as well
> fix it.
Nice catch.
> Btw, this is from code auditing and not from testing. I don't know
> if this affects anyone in real life.
FWIW, it doesn't, the max key length that makes sense is 32 anyway, and
since this is on an output path I doubt the min_t() will ever have done
anything but returned "tocopy" :-)
johannes
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
> index 6bc7c92..98fbf54 100644
> --- a/drivers/net/wireless/wl3501_cs.c
> +++ b/drivers/net/wireless/wl3501_cs.c
> @@ -1781,7 +1781,7 @@ static int wl3501_get_encode(struct net_device *dev,
> keys, len_keys);
> if (rc)
> goto out;
> - tocopy = min_t(u8, len_keys, wrqu->encoding.length);
> + tocopy = min_t(u16, len_keys, wrqu->encoding.length);
> tocopy = min_t(u8, tocopy, 100);
> wrqu->encoding.length = tocopy;
> memcpy(extra, keys, tocopy);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
prev parent reply other threads:[~2011-09-26 8:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-26 6:30 [patch] wl3501_cs: min_t() cast truncates high bits Dan Carpenter
2011-09-26 8:24 ` Johannes Berg [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=1317025477.4117.21.camel@jlt3.sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=acme@ghostprotocols.net \
--cc=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox