Skip to content

Commit

Permalink
fix freeze on linux 6.9
Browse files Browse the repository at this point in the history
Ref libreswan/libreswan#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
  • Loading branch information
Lanius-collaris authored and François-Simon Fauteux-Chapleau committed Jun 26, 2024
1 parent 797f1a3 commit 8fc165b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions pjlib/src/pj/ip_helper_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -558,6 +558,7 @@ static pj_status_t get_ipv6_deprecated(unsigned *count, pj_sockaddr addr[])
}
}
}
nlmsg_done:;

close(fd);
*count = idx;
Expand Down
7 changes: 4 additions & 3 deletions pjnath/src/pjnath/ice_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -886,6 +886,7 @@ static PJ_DEF(void) get_invalid_addresses(char** addresses, size_t* size)
}
}
}
nlmsg_done:;

close(fd);
*size = idx;
Expand Down

0 comments on commit 8fc165b

Please sign in to comment.