mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Julian Squires <julian@cipht.net>
To: musl@lists.openwall.com
Cc: Julian Squires <julian@cipht.net>,
	Bob Richmond <robert.richmond@greenwavesystems.com>
Subject: [musl] [PATCH] handle linux-specific errors in getaddrinfo AI_ADDRCONFIG
Date: Fri, 30 Apr 2021 15:26:13 -0230	[thread overview]
Message-ID: <20210430175612.27804-1-julian@cipht.net> (raw)

linux allows adding ip rules with actions such as RTN_PROHIBIT or
RTN_BLACKHOLE to the loopback interface, e.g.:

  ip -6 rule add from all iif lo lookup unspec prohibit

if the loopback interface also has ipv6 disabled:

  sysctl net/ipv6/conf/lo/disable_ipv6=1

the connect() in getaddrinfo will return EACCES or EINVAL,
respectively, and getaddrinfo will erroneously return early.

this may sound like a perverse misconfiguration, but it happens easily
on openwrt systems where ipv6 has been disabled, as openwrt's netifd
by default sets up these rules (with a custom RTN_POLICY_FAILED
action, which behaves like RTN_PROHIBIT in this case).

Signed-off-by: Julian Squires <julian@cipht.net>
Co-authored-by: Bob Richmond <robert.richmond@greenwavesystems.com>
---
 src/network/getaddrinfo.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/network/getaddrinfo.c b/src/network/getaddrinfo.c
index efaab306..9a9c3cbc 100644
--- a/src/network/getaddrinfo.c
+++ b/src/network/getaddrinfo.c
@@ -76,6 +76,8 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru
 			case EHOSTUNREACH:
 			case ENETDOWN:
 			case ENETUNREACH:
+			case EACCES:
+			case EINVAL:
 				break;
 			default:
 				return EAI_SYSTEM;
-- 
2.31.1


                 reply	other threads:[~2021-04-30 17:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210430175612.27804-1-julian@cipht.net \
    --to=julian@cipht.net \
    --cc=musl@lists.openwall.com \
    --cc=robert.richmond@greenwavesystems.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).