net: ice: Fix potential NULL pointer dereference in ice_bridge_setlink()
Subsystems (3)
PATCH 1/1 net: ice: Fix potential NULL pointer dereference in ice_bridge_setlink()
The function ice_bridge_setlink() may encounter a NULL pointer dereference if nlmsg_find_attr() returns NULL and br_spec is dereferenced subsequently in nla_for_each_nested(). To address this issue, add a check to ensure that br_spec is not NULL before proceeding with the nested attribute iteration.
--- drivers/net/ethernet/intel/ice/ice_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/intel/ice/ice_main.c +2 -0
@@ -6530,6 +6530,8 @@ ice_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh, pf_sw = pf->first_sw;/* find the attribute in the netlink message */ br_spec =nlmsg_find_attr (nlh,sizeof (struct ifinfomsg ),IFLA_AF_SPEC ); +if (!br_spec) +return -EINVAL ;nla_for_each_nested (attr, br_spec, rem) {__u16 mode;
Signature · 1 line
2.34.1
Quoted 6 lines · Rand Deeb
The function
ice_bridge_setlink()may encounter a NULL pointer dereference ifnlmsg_find_attr()returns NULL andbr_specis dereferenced subsequently innla_for_each_nested(). To address this issue, add a check to ensure thatbr_specis not NULL before proceeding with the nested attribute iteration.Signed-off-by Rand Deeb <[email protected]>
Thanks Rand,
I do wonder if for some reason this cannot ever occur. But assuming it can then I agree with the fix.
As a fix I think it probably warrants a fixes tag and being applied to net. As such, the following seems appropriate.
...