From: Matej Kupljen <matej.kupljen@gmail.com>
To: musl@lists.openwall.com
Subject: Endless loop in netlink_msg_to_ifaddr
Date: Wed, 30 May 2018 11:57:03 +0200 [thread overview]
Message-ID: <CAHMF36G5xM=M7RqpmrixA32rB+G3a4L6Vem1Lh2Wp4hKMEoKpw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1799 bytes --]
Hi all,
I am using OpenWRT device with MUSL C library version 1.1.19 and I am
running custom binary on it. I noticed that during testing my program
started using 99% CPU.
I build OpenWRT myself so I have all the sources. I attached the gdbserver
and checked what is going on.
What I found is that it executes this code:
static int netlink_msg_to_ifaddr(void *pctx, struct nlmsghdr *h)
{
struct ifaddrs_ctx *ctx = pctx;
struct ifaddrs_storage *ifs, *ifs0;
struct ifinfomsg *ifi = NLMSG_DATA(h);
struct ifaddrmsg *ifa = NLMSG_DATA(h);
struct rtattr *rta;
int stats_len = 0;
if (h->nlmsg_type == RTM_NEWLINK) {
for (rta = NLMSG_RTA(h, sizeof(*ifi)); NLMSG_RTAOK(rta, h); rta =
RTA_NEXT(rta)) {
if (rta->rta_type != IFLA_STATS) continue;
stats_len = RTA_DATALEN(rta);
break;
}
} else {
for (ifs0 = ctx->hash[ifa->ifa_index % IFADDRS_HASH_SIZE]; ifs0; ifs0 =
ifs0->hash_next)
if (ifs0->index == ifa->ifa_index)
break;
if (!ifs0) return 0;
}
From my GDB session:
(gdb) p *ctx
$10 = {first = 0xe1b0b0, last = 0xe1b1c0, hash = {0x0, 0xe1b0b0, 0xe1b1c0,
0x0 <repeats 61 times>}}
(gdb) p *h
$11 = {nlmsg_len = 1496, nlmsg_type = 16, nlmsg_flags = 2, nlmsg_seq = 1,
nlmsg_pid = 3143810850}
(gdb) p *ifi
$12 = {ifi_family = 0 '\000', __ifi_pad = 0 '\000', ifi_type = 1, ifi_index
= 3, ifi_flags = 69699, ifi_change = 0}
(gdb) p *ifa
$13 = {ifa_family = 0 '\000', ifa_prefixlen = 0 '\000', ifa_flags = 0
'\000', ifa_scope = 1 '\001', ifa_index = 3
(gdb) p *rta
$14 = {rta_len = 0, rta_type = 41}
As you can see the first message in netlink reply has a rta_len set to zero
so the list is never traversed, only the first message is received every
time.
I am not sure if this is the correct response from netlink, however the
program is stucked here.
Any ideas?
Please CC me in reply.
Thanks and BR,
Matej
[-- Attachment #2: Type: text/html, Size: 3158 bytes --]
next reply other threads:[~2018-05-30 9:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-30 9:57 Matej Kupljen [this message]
2018-05-30 12:45 ` Timo Teras
2018-06-02 1:44 ` Rich Felker
2018-06-02 17:36 ` Andrei Vagin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAHMF36G5xM=M7RqpmrixA32rB+G3a4L6Vem1Lh2Wp4hKMEoKpw@mail.gmail.com' \
--to=matej.kupljen@gmail.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).