From: David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 3/5] cifs: sanitize length checking in coalesce_t2
Date: Tue, 26 Apr 2011 15:27:32 +0100 [thread overview]
Message-ID: <17747.1303828052@redhat.com> (raw)
In-Reply-To: <1303819401-14789-4-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> - __u16 byte_count, total_data_size, total_in_buf, total_in_buf2;
> + unsigned int byte_count, total_in_buf;
> + __u16 total_data_size, total_in_buf2;
There's no particular need for any of these to be __u16; I'd recommend making
them all unsigned int or size_t.
> + /* did this field "wrap" ? */
> + if (total_in_buf & ~((1<<16)-1))
> + return -EINVAL;
I'd recommend something more like the following:
/* check the server isn't offering too much data */
if (total_in_buf > USHRT_MAX)
return -EINVAL;
rather than calculating a mask.
Also, would EPROTO be a better choice for packet parsing errors than EINVAL?
> + /* did this field "wrap" ? */
> + if (byte_count & ~((1<<16)-1))
> + return -EINVAL;
Ditto.
David
next prev parent reply other threads:[~2011-04-26 14:27 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-26 12:03 [PATCH 0/5] cifs: fix some bounds checking problems Jeff Layton
[not found] ` <1303819401-14789-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-04-26 12:03 ` [PATCH 1/5] cifs: change bleft in decode_unicode_ssetup back to signed type Jeff Layton
2011-04-26 12:03 ` [PATCH 2/5] cifs: check for bytes_remaining going to zero in CIFS_SessSetup Jeff Layton
2011-04-26 12:03 ` [PATCH 3/5] cifs: sanitize length checking in coalesce_t2 Jeff Layton
2011-04-26 12:03 ` [PATCH 4/5] cifs: refactor mid finding loop in cifs_demultiplex_thread Jeff Layton
2011-04-26 12:03 ` [PATCH 5/5] cifs: handle errors from coalesce_t2 Jeff Layton
2011-04-27 14:17 ` [PATCH 0/5] cifs: fix some bounds checking problems Jeff Layton
[not found] ` <20110427101740.32be5c28-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2011-04-27 14:59 ` Steve French
[not found] ` <BANLkTiko7K1HJFjAKfRokmFiWk=+rHe0DA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-04-27 15:04 ` Jeff Layton
[not found] ` <20110427110404.71b80c29-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2011-04-27 15:06 ` Steve French
[not found] ` <BANLkTinzFc5DgUuG9ohRQNGk12PDO7J-uQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-04-27 15:07 ` Steve French
[not found] ` <BANLkTikLYQg_zEWS5Joz=7eTj1P_YF6ZzQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-04-27 15:14 ` Jeff Layton
2011-04-29 5:05 ` Steve French
[not found] ` <BANLkTimNseyrXc9ZDz0N4tomRx1oy5P60Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-04-29 10:55 ` Jeff Layton
[not found] ` <1303819401-14789-2-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-04-26 14:10 ` [PATCH 1/5] cifs: change bleft in decode_unicode_ssetup back to signed type David Howells
[not found] ` <1303819401-14789-3-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-04-26 14:11 ` [PATCH 2/5] cifs: check for bytes_remaining going to zero in CIFS_SessSetup David Howells
[not found] ` <1303819401-14789-4-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-04-26 14:27 ` David Howells [this message]
[not found] ` <17747.1303828052-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-04-26 16:00 ` [PATCH 3/5] cifs: sanitize length checking in coalesce_t2 Jeff Layton
2011-04-27 12:03 ` [PATCH 3/5] cifs: sanitize length checking in coalesce_t2 (try #2) Jeff Layton
[not found] ` <1303905796-28087-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-04-27 16:37 ` David Howells
[not found] ` <13543.1303922232-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-04-27 16:43 ` Jeff Layton
2011-04-27 16:43 ` David Howells
2011-04-27 17:31 ` [PATCH] cifs: sanitize length checking in coalesce_t2 (try #3) Jeff Layton
[not found] ` <1303819401-14789-5-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-04-26 14:39 ` [PATCH 4/5] cifs: refactor mid finding loop in cifs_demultiplex_thread David Howells
2011-05-03 3:44 ` Steve French
[not found] ` <BANLkTim4jXoQm47-ecw8r5ftBVGRbA+mKw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-05-03 12:09 ` Jeff Layton
[not found] ` <20110503080953.65db9af6-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2011-05-03 14:50 ` Steve French
[not found] ` <1303819401-14789-6-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2011-04-26 14:40 ` [PATCH 5/5] cifs: handle errors from coalesce_t2 David Howells
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=17747.1303828052@redhat.com \
--to=dhowells-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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.