[lkml]   [2008]   [Sep]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] netlink: fix overrun in attribute iteration
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.

 \ /
  Last update: 2008-09-12 05:55    [W:0.058 / U:0.816 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site