[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <19f34abd0809112249j7d289caese42cfc019b4cac2c@mail.gmail.com>
Date: Fri, 12 Sep 2008 07:49:08 +0200
From: "Vegard Nossum" <vegard.nossum@...il.com>
To: "David Wagner" <daw-news@...berkeley.edu>
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH] netlink: fix overrun in attribute iteration
On Fri, Sep 12, 2008 at 5:51 AM, David Wagner <daw@...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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists