You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2025/10/21 09:43:54 UTC

[Bug 69857] New: Server initiates connections to INADDR_ANY (0.0.0.0) in mpm_unix.c

https://bz.apache.org/bugzilla/show_bug.cgi?id=69857

            Bug ID: 69857
           Summary: Server initiates connections to INADDR_ANY (0.0.0.0)
                    in mpm_unix.c
           Product: Apache httpd-2
           Version: 2.4.64
          Hardware: HP
                OS: OpenBSD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core
          Assignee: bugs@httpd.apache.org
          Reporter: samjvaughan@gmail.com
  Target Milestone: ---

After upgrading from OpenBSD 7.6 to 7.7, my server error logs have been filling
up with around a thousand messages per day as follows:

[Tue Oct 21 20:32:15.637924 2025] [core:warn] [pid 962] (22)Invalid argument:
AH00056: connect to listener on 0.0.0.0:8080

This is occurring because the dummy_connection() function in server/mpm_unix.c
issues socket connections to an address it pulls from the ap_listeners list,
and if the server is configured as e.g. Listen 80, this will be INADDR_ANY
(0.0.0.0).

OpenBSD doesn't support connect() to INADDR_ANY and returns EINVAL (22). 
Although other OSes have workarounds in connect(), Apache should be explicit
about the address it is trying to connect to.

In the OpenBSD 7.6 port of apr 1.7.2 there was a patch to replace the
INADDR_ANY address with the loopback address, but this actually had the
unintentional side effect of overwriting the address in the ap_listeners entry
used by dummy_connection().  It would then not be possible for Apache to tell
whether that listener was configured as Listen 80 or Listen 127.0.0.1:80.

The OpenBSD maintainers also had concerns about recent security issues on other
systems where the use of IN_ADDR_ANY has allowed security policy to be
bypassed.

For these reasons, the patch was removed for OpenBSD 7.7 so now the log files
are getting hammered, and the communication intended for ap_mpm_pod_signal()
and ap_mpm_pod_killpg() to work correctly is not occurring.

https://github.com/openbsd/ports/commit/007351bdc135b80a017ff8c3da67905ffff291e9

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 69857] Server initiates connections to INADDR_ANY (0.0.0.0) in mpm_unix.c

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69857

--- Comment #2 from Giovanni Bechis <gi...@paclan.it> ---
Hi Sam,
I am not able to replicate it on OpenBSD 7.9 (currently supported version);
if you want you can send me your httpd.conf in private so that I can check
further.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 69857] Server initiates connections to INADDR_ANY (0.0.0.0) in mpm_unix.c

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69857

--- Comment #6 from Joe Orton <jo...@redhat.com> ---
+1 thanks to you both.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 69857] Server initiates connections to INADDR_ANY (0.0.0.0) in mpm_unix.c

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69857

Giovanni Bechis <gi...@paclan.it> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #8 from Giovanni Bechis <gi...@paclan.it> ---
Sending        server/mpm_unix.c
Transmitting file data .done
Committing transaction...
Committed revision 1936893.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 69857] Server initiates connections to INADDR_ANY (0.0.0.0) in mpm_unix.c

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69857

Giovanni Bechis <gi...@paclan.it> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |PatchAvailable

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 69857] Server initiates connections to INADDR_ANY (0.0.0.0) in mpm_unix.c

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69857

--- Comment #3 from Sam Vaughan <sa...@gmail.com> ---
Created attachment 40205
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=40205&action=edit
Minimal https.conf file to reproduce 69857

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 69857] Server initiates connections to INADDR_ANY (0.0.0.0) in mpm_unix.c

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69857

--- Comment #4 from Sam Vaughan <sa...@gmail.com> ---
Hi Giovanni,

I won't pretend I wrote this - it's Claude's analysis of the bug because
it's been a while since I posted the report and my memory is hazy!

Thank you very much for looking at this.

Kind regards,

Sam


I've attached a minimal httpd.conf that
reproduces it (httpd-bug69857.conf, verified today on OpenBSD 7.8 with
the apache-httpd-2.4.65p0 package).  It turns out nothing in my
configuration is special - no vhosts, mod_perl or SSL are involved, and
the stock package httpd2.conf already has both configuration
prerequisites: mpm_prefork is the MPM the sample config enables, and
"Listen 80" is a wildcard listener.

The reason a quick test doesn't show it is that the trigger is a
traffic pattern, not the configuration.  dummy_connection() in
server/mpm_unix.c is only reached from ap_mpm_pod_signal(), which
prefork's perform_idle_server_maintenance() calls when idle_count >
MaxSpareServers.  A freshly started server sits at StartServers
children and never crosses that threshold, so dummy_connection() is
never called no matter how long it runs or how many sequential
requests you send.  (Graceful restart/stop also can't produce the log
flood: ap_mpm_pod_killpg() only makes dummy connections for
SERVER_READY scoreboard slots and stops at the first failure, so it
logs at most one line - in my tests it logged none.)

Reproduction with the attached conf:

  # httpd2 -f /etc/apache2/httpd-bug69857.conf
  # for i in $(jot 10); do nc -w 12 127.0.0.1 8099 </dev/null & done

The ten idle connections force prefork to fork extra children.  About
13 seconds later, when nc times out and the connections close, the
children go idle, idle_count exceeds MaxSpareServers, and the culling
starts:

  [Mon Aug 03 14:13:37.326455 2026] [core:warn] [pid 13676] (22)Invalid
argument: AH00056: connect to listener on [::]:8099
  [Mon Aug 03 14:13:38.335989 2026] [core:warn] [pid 13676] (22)Invalid
argument: AH00056: connect to listener on [::]:8099
  [Mon Aug 03 14:13:39.346144 2026] [core:warn] [pid 13676] (22)Invalid
argument: AH00056: connect to listener on [::]:8099
  ...

(In this minimal config the first listener is the IPv6 wildcard; on my
production server, with "Listen 80" plus "Listen 8080", the chosen
listener is 0.0.0.0:8080.  connect() to either wildcard fails with
EINVAL on OpenBSD.)

Note that it logs one warning per second *indefinitely*, not one per
culled child: the dummy connection is the only mechanism that wakes a
child blocked in accept(), so no child ever reads the pipe-of-death
byte, idle_count never drops, and the parent retries every second.
Each real request wakes one child, which then sees the pod byte and
exits - so on a live server the flood self-sustains between traffic
bursts, which is where my ~1000 messages/day come from.  The
functional impact is that excess idle children are only reaped as fast
as new requests arrive.

Two data points supporting the diagnosis: changing the listeners to
"Listen 127.0.0.1:<port>" on one of our servers stopped the messages
completely (16,648 in the previous log period, zero since), and the
same wildcard config was silent on OpenBSD <= 7.6 because the ports
patch then rewrote the connect() address to loopback inside
apr_socket_connect().

Joe's suggestion in comment 1 matches what the OpenBSD ports commit
recommends: substitute the loopback address (127.0.0.1 / ::1, matching
lp->bind_addr->family) at connect time inside dummy_connection() when
bind_addr is the wildcard, without touching lp->bind_addr itself.  I'm
happy to test a patch on OpenBSD.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 69857] Server initiates connections to INADDR_ANY (0.0.0.0) in mpm_unix.c

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69857

--- Comment #5 from Giovanni Bechis <gi...@paclan.it> ---
Created attachment 40206
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=40206&action=edit
silence dummy connection warnings

Attached patch silence the warnings.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 69857] Server initiates connections to INADDR_ANY (0.0.0.0) in mpm_unix.c

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69857

--- Comment #1 from Joe Orton <jo...@redhat.com> ---
We could have an BSD-specific ifdef in that function to fall back to using
127.0.0.1 if lp->bind_addr is INADDR_ANY and that connect() fails with EINVAL,
but someone on an affected BSD should write that and submit it.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 69857] Server initiates connections to INADDR_ANY (0.0.0.0) in mpm_unix.c

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69857

--- Comment #7 from Sam Vaughan <sa...@gmail.com> ---
Thanks Giovanni.

Verified on OpenBSD 7.9 with Apache 2.4.66 that it eliminates the AH00056 flood
entirely. (0 warnings vs 28-and-climbing stock)

It also restores the idle-child culling mechanism (children returned to
MaxSpareServers within seconds, whereas the stock build left them stuck
indefinitely).  Graceful stop is clean too.

+1, much appreciated.

Sam

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org