mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 08:15:07 -04:00
netdev: check for nla_put_u32() failures
Make sure we check if nla_put_u32(id) was successful after creating objects. This is theoretical today, the skbs are large enough to always fit the ID. Acked-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org> Reviewed-by: Joe Damato <joe@dama.to> Link: https://patch.msgid.link/20260809000609.327659-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
@@ -1107,7 +1107,9 @@ int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info)
|
||||
goto err_unbind;
|
||||
}
|
||||
|
||||
nla_put_u32(rsp, NETDEV_A_DMABUF_ID, binding->id);
|
||||
/* rsp was allocated large enough */
|
||||
WARN_ON_ONCE(nla_put_u32(rsp, NETDEV_A_DMABUF_ID, binding->id));
|
||||
|
||||
genlmsg_end(rsp, hdr);
|
||||
|
||||
err = genlmsg_reply(rsp, info);
|
||||
@@ -1241,7 +1243,9 @@ int netdev_nl_bind_tx_doit(struct sk_buff *skb, struct genl_info *info)
|
||||
goto err_unlock_bind_dev;
|
||||
}
|
||||
|
||||
nla_put_u32(rsp, NETDEV_A_DMABUF_ID, binding->id);
|
||||
/* rsp was allocated large enough */
|
||||
WARN_ON_ONCE(nla_put_u32(rsp, NETDEV_A_DMABUF_ID, binding->id));
|
||||
|
||||
genlmsg_end(rsp, hdr);
|
||||
|
||||
if (bind_dev != netdev)
|
||||
@@ -1408,7 +1412,9 @@ int netdev_nl_queue_create_doit(struct sk_buff *skb, struct genl_info *info)
|
||||
|
||||
netdev_rx_queue_lease(rxq, rxq_lease);
|
||||
|
||||
nla_put_u32(rsp, NETDEV_A_QUEUE_ID, queue_id);
|
||||
/* rsp was allocated large enough */
|
||||
WARN_ON_ONCE(nla_put_u32(rsp, NETDEV_A_QUEUE_ID, queue_id));
|
||||
|
||||
genlmsg_end(rsp, hdr);
|
||||
|
||||
netdev_unlock(dev_lease);
|
||||
|
||||
Reference in New Issue
Block a user