mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Vegard Nossum" <vegard.nossum@gmail.com>
To: "David Wagner" <daw-news@cs.berkeley.edu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] netlink: fix overrun in attribute iteration
Date: Fri, 12 Sep 2008 07:49:08 +0200	[thread overview]
Message-ID: <19f34abd0809112249j7d289caese42cfc019b4cac2c@mail.gmail.com> (raw)
In-Reply-To: <gacp0q$drj$1@taverner.cs.berkeley.edu>

On Fri, Sep 12, 2008 at 5:51 AM, David Wagner <daw@cs.berkeley.edu> wrote:
> 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.

Hm. Yes, it would!

The problem here is that "remaining" can legitimately contain negative
values (see the pointer advancement in nla_next()). And size_t can't
hold negative values.


Vegard

-- 
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
	-- E. W. Dijkstra, EWD1036

      reply	other threads:[~2008-09-12  5:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-11 20:59 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
2008-09-12  5:49   ` Vegard Nossum [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=19f34abd0809112249j7d289caese42cfc019b4cac2c@mail.gmail.com \
    --to=vegard.nossum@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®