From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31381 invoked from network); 13 Jun 2022 15:46:49 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 13 Jun 2022 15:46:49 -0000 Received: (qmail 17663 invoked by uid 550); 13 Jun 2022 15:46:45 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 15432 invoked from network); 13 Jun 2022 15:42:20 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=lpFX8gYZuKEu1PNJ9K4shNj/Mq9qQfxYqp7DZcrsZnc=; b=HGU7vsIZYWkuyr3Pw0gDk2QcFDkPxwx04LRwsy3GHu2fYChrkflFadjaW9cBaY+dWT HQRLZBMSLtmq/WNA0hkHLFzLmFZNJxeQ60+vc89BFT93C84iO/6pF25FgpYEHQwkZ7Gg ik6SdVozIdm0PNucgR+wW3xu94C00EXckPImj1nVMp/fvK+QRkvbsSbfWlYY5KQIV/iY 4GFpcPpLqoHFxmTzghBd73NPdWwiGvyw4hC4ESZIreNj1pXMykZIg4qG2QqSjesWdnGw Wujx+NgKalhpUEBlynHTGGgJ7kE15W5L9Qc1d0WtNhS0iWSXkNSP7gdSq/LJDH6a/Pde 740w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=lpFX8gYZuKEu1PNJ9K4shNj/Mq9qQfxYqp7DZcrsZnc=; b=PZW5OpOpkG6xuus79dZByXWsp5dHO/O4/lTG4VkVJ8SZHunWPItqRLv11JqKk7lrST //6cmVGCzVObK/pIetja4joPyGV560VJK+Is/cMyCxArA4fA+PPHJvg1pdeRBI6WUzEi R232lC5/qZDpKAKNdPwX+PH75mkLC6nIH1BkzDc50FjDD1l2dX2qGZZXZ/9dqTJG2nra Zlv6mf/znkX+NSo0a+g1lALqX9Xq7RD5xdgZlpI0encT3hG486AhLGsMvr4HFY21wQAd ko9ewccYKN5LxNdqqzkbT8XtJ6kXIIhY1FFAy/5lsrrCYtmOric7VYqbZlnw5dvyKGun Yr9w== X-Gm-Message-State: AJIora9wsYRC87NK3t2Ma3Ts+coftmJ/LFcTTKlSuA0jqKQbYlxweQQj fnadT4cN1tYOw6FQmPtKsXijvWBNlR7dZnYVnotFY5zVxlM= X-Google-Smtp-Source: AGRyM1syOWB+BXiEHdTUu67vwvX06ccfsmHz0qx99NUtJicTX+SmgChzLFm91bjNQkFOYGLEcgb9SAfVRSeyyIRFFCs= X-Received: by 2002:a2e:96c9:0:b0:258:ac98:5304 with SMTP id d9-20020a2e96c9000000b00258ac985304mr97090ljj.382.1655134928547; Mon, 13 Jun 2022 08:42:08 -0700 (PDT) MIME-Version: 1.0 From: Waldek Kozaczuk Date: Mon, 13 Jun 2022 11:41:57 -0400 Message-ID: To: musl@lists.openwall.com Content-Type: multipart/alternative; boundary="00000000000078b3ad05e156215f" Subject: [musl] netlink.c: missing handling of EAGAIN and EWOULDBLOCK --00000000000078b3ad05e156215f Content-Type: text/plain; charset="UTF-8" Hi, Very recently we implemented minimal rnetlink support on OSv side which allowed us to finally switch to the netlink-based implementation of getifaddrs() and if_nameindex(). However, I noticed that the function __netlink_enumerate() in https://github.com/ifduyue/musl/blob/master/src/network/netlink.c uses MSG_DONTWAIT flag when calling recv() which may fail with EAGAIN or EWOULDBLOCK and there is no error/retry handling for that. I actually saw both functions fail occasionally on OSv. One way to fix is to add missing error handling. But another simpler solution is to stop using MSG_DONTWAIT altogether and force recv() to block. In other words, the line: r = recv(fd, u.buf, sizeof(u.buf), MSG_DONTWAIT); should change to: r = recv(fd, u.buf, sizeof(u.buf), 0); For time being we are applying a header trick on OSv side to re-define MSG_DONTWAIT as 0 when compiling those specific musl sources. Waldek --00000000000078b3ad05e156215f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

Very recently we implemented minima= l rnetlink support on OSv side which allowed us to finally switch to the ne= tlink-based implementation of getifaddrs() and if_nameindex().
However, I noticed=C2=A0that the function=C2=A0__netlink_enumerate()=C2=A0in https://github.com= /ifduyue/musl/blob/master/src/network/netlink.c uses MSG_DONTWAIT flag = when calling recv() which may fail with=C2=A0EAGAIN or EWOULDBLOCK and ther= e is no error/retry handling for that. I actually saw both functions fail o= ccasionally on OSv.

One way to fix is=C2=A0to add = missing error handling. But another simpler solution is to stop using MSG_D= ONTWAIT altogether and force recv() to block. In other words, the line:

r =3D recv(fd, u.buf, sizeof(u.buf), MSG= _DONTWAIT);

should change to:

r =3D recv(fd, u.buf, sizeof(u.buf), 0);

For time being we are applying a header tric= k on OSv side to re-define MSG_DONTWAIT as 0 when compiling those specific = musl sources.

Waldek=C2=A0


--00000000000078b3ad05e156215f--