Skip to content

Commit 9a8a26a

Browse files
committed
if: guard against if_ioctl being NULL
There are situations where an struct ifnet has a NULL if_ioctl pointer. For example, e6000sw creates such struct ifnets for each of its ports so it can call into the MII code. If there is then a link state event this calls do_link_state_change() -> rtnl_handle_ifevent() -> dump_iface() -> get_operstate() -> get_operstate_ether(). That wants to know if the link is up or down, so it tries to ioctl(SIOCGIFMEDIA), which doesn't go well if if_ioctl is NULL. Guard against this, and return EOPNOTSUPP. PR: 275920 MFC ater: 3 days Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 43387b4)
1 parent eabd804 commit 9a8a26a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sys/net/if.c

+3
Original file line numberDiff line numberDiff line change
@@ -4873,6 +4873,9 @@ if_resolvemulti(if_t ifp, struct sockaddr **srcs, struct sockaddr *dst)
48734873
int
48744874
if_ioctl(if_t ifp, u_long cmd, void *data)
48754875
{
4876+
if (ifp->if_ioctl == NULL)
4877+
return (EOPNOTSUPP);
4878+
48764879
return (ifp->if_ioctl(ifp, cmd, data));
48774880
}
48784881

0 commit comments

Comments
 (0)