summaryrefslogtreecommitdiff
path: root/drivers/connector
diff options
context:
space:
mode:
authorMathias Krause <minipli@googlemail.com>2013-09-30 22:03:07 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-11-04 04:31:02 -0800
commit69b9c5ea567e5c9b202b3e5bcac3c2eb72270e0b (patch)
tree55fd165c516942c1e433d69e2ced45498930e411 /drivers/connector
parent39283085a92262f9446b95d36df9724902b7579a (diff)
downloadlinux-3.10-69b9c5ea567e5c9b202b3e5bcac3c2eb72270e0b.tar.gz
linux-3.10-69b9c5ea567e5c9b202b3e5bcac3c2eb72270e0b.tar.bz2
linux-3.10-69b9c5ea567e5c9b202b3e5bcac3c2eb72270e0b.zip
connector: use nlmsg_len() to check message length
[ Upstream commit 162b2bedc084d2d908a04c93383ba02348b648b0 ] 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. Signed-off-by: Mathias Krause <minipli@googlemail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/connector')
-rw-r--r--drivers/connector/connector.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index 6ecfa758942..0daa11e418b 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -157,17 +157,18 @@ static int cn_call_callback(struct sk_buff *skb)
static void cn_rx_skb(struct sk_buff *__skb)
{
struct nlmsghdr *nlh;
- int err;
struct sk_buff *skb;
+ int len, err;
skb = skb_get(__skb);
if (skb->len >= NLMSG_HDRLEN) {
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 ||
- nlh->nlmsg_len > CONNECTOR_MAX_MSG_SIZE) {
+ len > CONNECTOR_MAX_MSG_SIZE) {
kfree_skb(skb);
return;
}