netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: jslaby@suse.cz
Cc: vyasevich@gmail.com, linux-kernel@vger.kernel.org,
	nhorman@tuxdriver.com, linux-sctp@vger.kernel.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH] net: sctp, forbid negative length
Date: Sun, 23 Oct 2016 17:44:05 -0400 (EDT)	[thread overview]
Message-ID: <20161023.174405.1335530959467229046.davem@davemloft.net> (raw)
In-Reply-To: <20161021121324.13942-1-jslaby@suse.cz>

From: Jiri Slaby <jslaby@suse.cz>
Date: Fri, 21 Oct 2016 14:13:24 +0200

> Most of getsockopt handlers in net/sctp/socket.c check len against
> sizeof some structure like:
>         if (len < sizeof(int))
>                 return -EINVAL;
> 
> On the first look, the check seems to be correct. But since len is int
> and sizeof returns size_t, int gets promoted to unsigned size_t too. So
> the test returns false for negative lengths. Yes, (-1 < sizeof(long)) is
> false.
> 
> Fix this in sctp by explicitly checking len < 0 before any getsockopt
> handler is called.
> 
> Note that sctp_getsockopt_events already handled the negative case.
> Since we added the < 0 check elsewhere, this one can be removed.
> 
> If not checked, this is the result:
...
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>

Applied and queued up for -stable, thanks.

      parent reply	other threads:[~2016-10-23 21:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-21 12:13 [PATCH] net: sctp, forbid negative length Jiri Slaby
2016-10-21 12:39 ` Neil Horman
2016-10-23 21:44 ` David Miller [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=20161023.174405.1335530959467229046.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sctp@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=vyasevich@gmail.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;
as well as URLs for NNTP newsgroup(s).