Skip to content

Commit

Permalink
netlink: Warn on unordered or illegal nla_nest_cancel() or nlmsg_canc…
Browse files Browse the repository at this point in the history
…el()

Calling nla_nest_cancel() in a different order as the nesting was
built up can lead to negative offsets being calculated which
results in skb_trim() being called with an underflowed unsigned
int. Warn if mark < skb->data as it's definitely a bug.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Thomas Graf authored and David S. Miller committed Jan 6, 2015
1 parent a515abd commit 149118d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/net/netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,10 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
*/
static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
{
if (mark)
if (mark) {
WARN_ON((unsigned char *) mark < skb->data);
skb_trim(skb, (unsigned char *) mark - skb->data);
}
}

/**
Expand Down

0 comments on commit 149118d

Please sign in to comment.