Skip to contentSkip to conversation

netlink: Use netlink header as base to calculate bad attribute offset

PATCH In review Pablo Neira Ayuso 2 participants 2 messages Feb 26, 2020 – Mar 1, 2020

Subsystems (3)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 netlink: Use netlink header as base to calculate bad attribute offset

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")
---
 net/netlink/af_netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netlink/af_netlink.c +1 -1
index edf3e285e242..5313f1cec170 100644
@@ -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,
Signature · 1 line
2.11.0
maintainer
#1 lore raw

From: Pablo Neira Ayuso <[email protected]>
Date: Wed, 26 Feb 2020 19:47:34 +0100

Quoted 6 lines

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")

Applied and queued up for -stable, thanks Pablo.