From: daw@cs.berkeley.edu (David Wagner)
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] netlink: fix overrun in attribute iteration
Date: Fri, 12 Sep 2008 03:51:54 +0000 (UTC) [thread overview]
Message-ID: <gacp0q$drj$1@taverner.cs.berkeley.edu> (raw)
In-Reply-To: 20080911205933.GA20032@localhost.localdomain
Vegard Nossum wrote:
> /**
> * nla_ok - check if the netlink attribute fits into the remaining bytes
> * @nla: netlink attribute
> * @remaining: number of bytes remaining in attribute stream
> */
> static inline int nla_ok(const struct nlattr *nla, int remaining)
> {
> return remaining >= sizeof(*nla) &&
> nla->nla_len >= sizeof(*nla) &&
> nla->nla_len <= remaining;
> }
If 'remaining' had been declared to be of type size_t, this would
not have happened.
Guideline for secure programming: length values (and counts of bytes)
should be declared as size_t, where possible.
This guideline eliminates many signed/unsigned bugs. If one also
carefully avoids overflow (wraparound), other integer overflow bugs
are avoided as well.
The code above violates the guideline so we shouldn't be terribly
surprised if it happens to contain signed/unsigned vulnerabilities.
next prev parent reply other threads:[~2008-09-12 3:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-11 20:59 [PATCH] netlink: fix overrun in attribute iteration Vegard Nossum
2008-09-11 22:04 ` David Miller
2008-09-12 0:35 ` Thomas Graf
2008-09-12 2:05 ` David Miller
2008-09-11 23:52 ` Andrew Morton
2008-09-12 5:42 ` Vegard Nossum
2008-09-12 6:02 ` Andrew Morton
2008-09-12 3:51 ` David Wagner [this message]
2008-09-12 5:49 ` Vegard Nossum
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='gacp0q$drj$1@taverner.cs.berkeley.edu' \
--to=daw@cs.berkeley.edu \
--cc=daw-news@cs.berkeley.edu \
--cc=linux-kernel@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 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.