blob: 56ecbbe2759e2a000ab82458a8ed9941f54849bf [file] [log] [blame]
From d87e50221186c9d7e21b99fc770248aa3b61c26c Mon Sep 17 00:00:00 2001
From: Pablo Neira Ayuso <>
Date: Wed, 26 Feb 2020 19:47:34 +0100
Subject: [PATCH] netlink: Use netlink header as base to calculate bad
attribute offset
commit 84b3268027641401bb8ad4427a90a3cce2eb86f5 upstream.
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 <>
Signed-off-by: David S. Miller <>
Signed-off-by: Paul Gortmaker <>
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index bd056ec269f1..b7db1f99fc70 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2439,7 +2439,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err,
WARN_ON(nla_put_u32(skb, NLMSGERR_ATTR_OFFS,
(u8 *)extack->bad_attr -
- in_skb->data));
+ (u8 *)nlh));
} else {
if (extack->cookie_len)