From: David Miller <davem@davemloft.net>
To: ncardwell@google.com
Cc: edumazet@google.com, netdev@vger.kernel.org
Subject: Re: [PATCH net] inet_diag: validate port comparison byte code to prevent unsafe reads
Date: Sun, 09 Dec 2012 19:02:23 -0500 (EST) [thread overview]
Message-ID: <20121209.190223.1179297442063515404.davem@davemloft.net> (raw)
In-Reply-To: <1355086980-30438-1-git-send-email-ncardwell@google.com>
From: Neal Cardwell <ncardwell@google.com>
Date: Sun, 9 Dec 2012 16:03:00 -0500
> Add logic to verify that a port comparison byte code operation
> actually has the second inet_diag_bc_op from which we read the port
> for such operations.
>
> Previously the code blindly referenced op[1] without first checking
> whether a second inet_diag_bc_op struct could fit there. So a
> malicious user could make the kernel read 4 bytes beyond the end of
> the bytecode array by claiming to have a whole port comparison byte
> code (2 inet_diag_bc_op structs) when in fact the bytecode was not
> long enough to hold both.
>
> Signed-off-by: Neal Cardwell <ncardwell@google.com>
Haste makes waste...
> +/* Validate a port comparison operator. */
> +static inline bool valid_port_comparison(const struct inet_diag_bc_op *op,
> + int len, int *min_len)
> +{
> + /* Port comparisons put the port in a follow-on inet_diag_bc_op. */
> + *min_len += sizeof(struct inet_diag_bc_op);
> + if (len < *min_len)
> + return false;
> +}
> +
I added the missing "return true" at the end of this new function.
Applied, but please be more careful and at least look at the compiler
warnings when you submit your changes.
Thanks.
next prev parent reply other threads:[~2012-12-10 0:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-09 21:03 [PATCH net] inet_diag: validate port comparison byte code to prevent unsafe reads Neal Cardwell
2012-12-10 0:02 ` David Miller [this message]
2012-12-10 5:17 ` Neal Cardwell
-- strict thread matches above, loose matches on Subject: below --
2012-12-09 21:09 Neal Cardwell
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=20121209.190223.1179297442063515404.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.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 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).