Message ID | 20241114-fix-netlink_ack_tlv_fill-v2-1-affdfb5f4c6f@iiitd.ac.in (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net,v2] netlink: Add string check in netlink_ack_tlv_fill | expand |
On Thu, 14 Nov 2024 06:15:15 +0530 Manas via B4 Relay wrote: > - if (extack->bad_attr && > + if (extack->bad_attr && strlen(in_skb->data) && > !WARN_ON((u8 *)extack->bad_attr < in_skb->data || > (u8 *)extack->bad_attr >= in_skb->data + in_skb->len)) that's most definitely not the right fix. in_skb->data points to binary data. my best idea so far is to rework this check to use nlh, because in_skb will be pulled at this stage for dumps if that makes sense to you please give it a go, otherwise I'll work on the fix tomorrow
On 13.11.2024 18:25, Jakub Kicinski wrote: >On Thu, 14 Nov 2024 06:15:15 +0530 Manas via B4 Relay wrote: >> - if (extack->bad_attr && >> + if (extack->bad_attr && strlen(in_skb->data) && >> !WARN_ON((u8 *)extack->bad_attr < in_skb->data || >> (u8 *)extack->bad_attr >= in_skb->data + in_skb->len)) > >that's most definitely not the right fix. >in_skb->data points to binary data. > >my best idea so far is to rework this check to use nlh, because in_skb >will be pulled at this stage for dumps >if that makes sense to you please give it a go, otherwise I'll work on >the fix tomorrow Hi Jakub, thanks for reviewing this. I'll work on this.
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 0a9287fadb47a2afaf0babe675738bc43051c5a7..ea205a4f81e9755a229d46a7e617ce0c090fe5e3 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -2205,7 +2205,7 @@ netlink_ack_tlv_fill(struct sk_buff *in_skb, struct sk_buff *skb, if (!err) return; - if (extack->bad_attr && + if (extack->bad_attr && strlen(in_skb->data) && !WARN_ON((u8 *)extack->bad_attr < in_skb->data || (u8 *)extack->bad_attr >= in_skb->data + in_skb->len)) WARN_ON(nla_put_u32(skb, NLMSGERR_ATTR_OFFS,