From: Felix Fietkau Date: Thu, 25 Aug 2022 19:09:24 +0000 (+0200) Subject: interface: fix use-after-free bug when rewriting resolv.conf X-Git-Url: http://git.openwrt.org/b27977b41be6d010c9d5a8fc67e5e48135f11aae.?a=commitdiff_plain;h=76d2d41b7355e02f95fbfa79affbd232fb090595;p=project%2Fnetifd.git interface: fix use-after-free bug when rewriting resolv.conf After the call to interface_handle_config_change, the iface pointer will no longer be valid if the interface has been deleted from the config Signed-off-by: Felix Fietkau --- diff --git a/interface.c b/interface.c index 255ce84..89654f9 100644 --- a/interface.c +++ b/interface.c @@ -771,12 +771,13 @@ interface_proto_event_cb(struct interface_proto_state *state, enum interface_pro netifd_log_message(L_NOTICE, "Interface '%s' is now down\n", iface->name); mark_interface_down(iface); + interface_write_resolv_conf(iface->jail); if (iface->main_dev.dev) device_release(&iface->main_dev); if (iface->l3_dev.dev) device_remove_user(&iface->l3_dev); interface_handle_config_change(iface); - break; + return; case IFPEV_LINK_LOST: if (iface->state != IFS_UP) return;