From 8fc165b833eea6e3c88d67a541385424b129fd3f Mon Sep 17 00:00:00 2001 From: Lanius-collaris Date: Mon, 24 Jun 2024 16:44:18 +0800 Subject: [PATCH] fix freeze on linux 6.9 Ref https://github.com/libreswan/libreswan/issues/1675 We should not expect NLMSG_DONE to be sent in a separate message. This patch checks the nlmsg_type of every nlmsghdr. https://git.jami.net/savoirfairelinux/jami-daemon/-/issues/1006 Change-Id: I6f0957885cd419f3a1fd9f83f47d0fae0d63c423 --- pjlib/src/pj/ip_helper_generic.c | 7 ++++--- pjnath/src/pjnath/ice_session.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pjlib/src/pj/ip_helper_generic.c b/pjlib/src/pj/ip_helper_generic.c index 478c6b12f..f40aafc85 100644 --- a/pjlib/src/pj/ip_helper_generic.c +++ b/pjlib/src/pj/ip_helper_generic.c @@ -514,12 +514,12 @@ static pj_status_t get_ipv6_deprecated(unsigned *count, pj_sockaddr addr[]) if (nlmsg_len < sizeof (struct nlmsghdr)) return PJ_ETOOSMALL; - if (nlmsg_ptr->nlmsg_type == NLMSG_DONE) - break; - for(; NLMSG_OK(nlmsg_ptr, nlmsg_len); nlmsg_ptr = NLMSG_NEXT(nlmsg_ptr, nlmsg_len)) { + if (nlmsg_ptr->nlmsg_type == NLMSG_DONE) + goto nlmsg_done; + struct ifaddrmsg *ifaddrmsg_ptr; struct rtattr *rtattr_ptr; int ifaddrmsg_len; @@ -558,6 +558,7 @@ static pj_status_t get_ipv6_deprecated(unsigned *count, pj_sockaddr addr[]) } } } + nlmsg_done:; close(fd); *count = idx; diff --git a/pjnath/src/pjnath/ice_session.c b/pjnath/src/pjnath/ice_session.c index f1448ff88..774a6cce9 100644 --- a/pjnath/src/pjnath/ice_session.c +++ b/pjnath/src/pjnath/ice_session.c @@ -838,12 +838,12 @@ static PJ_DEF(void) get_invalid_addresses(char** addresses, size_t* size) return; } - if (nlmsg_ptr->nlmsg_type == NLMSG_DONE) - break; - for(; NLMSG_OK(nlmsg_ptr, nlmsg_len); nlmsg_ptr = NLMSG_NEXT(nlmsg_ptr, nlmsg_len)) { + if (nlmsg_ptr->nlmsg_type == NLMSG_DONE) + goto nlmsg_done; + struct ifaddrmsg *ifaddrmsg_ptr; struct rtattr *rtattr_ptr; int ifaddrmsg_len; @@ -886,6 +886,7 @@ static PJ_DEF(void) get_invalid_addresses(char** addresses, size_t* size) } } } + nlmsg_done:; close(fd); *size = idx;