]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
netlink: Use netlink header as base to calculate bad attribute offset
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 26 Feb 2020 18:47:34 +0000 (19:47 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 1 Mar 2020 05:21:23 +0000 (21:21 -0800)
Userspace might send a batch that is composed of several netlink
messages. The netlink_ack() function must use the pointer to the netlink
header as base to calculate the bad attribute offset.

Fixes: 2d4bc93368f5 ("netlink: extended ACK reporting")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/netlink/af_netlink.c

index edf3e285e242877d78b044bac89b4a41804b56cb..5313f1cec17063fb048ad80fdf0a567c4dc7357f 100644 (file)
@@ -2434,7 +2434,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err,
                                                               in_skb->len))
                                WARN_ON(nla_put_u32(skb, NLMSGERR_ATTR_OFFS,
                                                    (u8 *)extack->bad_attr -
-                                                   in_skb->data));
+                                                   (u8 *)nlh));
                } else {
                        if (extack->cookie_len)
                                WARN_ON(nla_put(skb, NLMSGERR_ATTR_COOKIE,