aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2024-05-06 09:39:08 +0000
committerKristof Provost <kp@FreeBSD.org>2024-05-20 07:38:40 +0000
commitfecd303882565954f58d984e4a13735e080b5263 (patch)
tree05377d13eb56b5522c5b2ca995d5bbabb9c243e9
parent2a964a7fc34e43fe29265a5f53c618fb1f4ac4c7 (diff)
downloadsrc-releng/14.1.tar.gz
src-releng/14.1.zip
if: guard against if_ioctl being NULLreleng/14.1
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 Approved by: re (cperciva) Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 43387b4e574043b78a58c8bcb7575161b055fce1) (cherry picked from commit 9a8a26aefb366ef6f497d48547a1562a1de566c1)
-rw-r--r--sys/net/if.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 0128fb8039ee..1ca0893eb724 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -4873,6 +4873,9 @@ if_resolvemulti(if_t ifp, struct sockaddr **srcs, struct sockaddr *dst)
int
if_ioctl(if_t ifp, u_long cmd, void *data)
{
+ if (ifp->if_ioctl == NULL)
+ return (EOPNOTSUPP);
+
return (ifp->if_ioctl(ifp, cmd, data));
}