Commit 162b2bed authored by Mathias Krause's avatar Mathias Krause Committed by David S. Miller

connector: use nlmsg_len() to check message length

The current code tests the length of the whole netlink message to be
at least as long to fit a cn_msg. This is wrong as nlmsg_len includes
the length of the netlink message header. Use nlmsg_len() instead to
fix this "off-by-NLMSG_HDRLEN" size check.

Cc: stable@vger.kernel.org  # v2.6.14+
Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e727ca82
...@@ -157,17 +157,18 @@ static int cn_call_callback(struct sk_buff *skb) ...@@ -157,17 +157,18 @@ static int cn_call_callback(struct sk_buff *skb)
static void cn_rx_skb(struct sk_buff *__skb) static void cn_rx_skb(struct sk_buff *__skb)
{ {
struct nlmsghdr *nlh; struct nlmsghdr *nlh;
int err;
struct sk_buff *skb; struct sk_buff *skb;
int len, err;
skb = skb_get(__skb); skb = skb_get(__skb);
if (skb->len >= NLMSG_HDRLEN) { if (skb->len >= NLMSG_HDRLEN) {
nlh = nlmsg_hdr(skb); nlh = nlmsg_hdr(skb);
len = nlmsg_len(nlh);
if (nlh->nlmsg_len < sizeof(struct cn_msg) || if (len < (int)sizeof(struct cn_msg) ||
skb->len < nlh->nlmsg_len || skb->len < nlh->nlmsg_len ||
nlh->nlmsg_len > CONNECTOR_MAX_MSG_SIZE) { len > CONNECTOR_MAX_MSG_SIZE) {
kfree_skb(skb); kfree_skb(skb);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment