From 76d2d41b7355e02f95fbfa79affbd232fb090595 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 25 Aug 2022 21:09:24 +0200 Subject: [PATCH] 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 --- interface.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; -- 2.30.2