NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
port-amd64/60867: allow disabling inetd(8) instance spawn limit
>Number: 60867
>Category: port-amd64
>Synopsis: allow disabling inetd(8) instance spawn limit
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: port-amd64-maintainer
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Oct 11 08:25:00 +0000 2026
>Originator: Paul Rankin
>Release: 11.0
>Organization:
>Environment:
NetBSD avalon.blip.town 11.0 NetBSD 11.0 (GENERIC) #0: Thu Jul 30 15:23:12 UTC 2026 mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
Currently inetd(8) shuts down connections for 10 minutes if it spawns more than 40 instances of a service within 60 seconds. This can be adjusted with nowait:max. I'm currently settings max to 1000000 to effectively disable this feature, since I do not want a 10 minutes shutdown under any circumstances. This is a hack and I think it would be cleaner to accept an argument of 0 to set no max.
Currently setting 0 is a literal zero, meaning the service would die for 10 minutes upon any connection, which no one would knowingly use because it's the same as not opening the port to begin with.
The argument could be made that this opens the system up to DDOS attacks, but it should be for the system admin to decide on that risk, not have it forced upon them.
>How-To-Repeat:
In inetd.conf:
127.0.0.1:9000 stream tcp nowait:100 root /dev/null
Make 100 connections to port 9000.
>Fix:
This patch is LLM generated. It applies to -current.
>From ceae4dc444169fce349030c8b208d08b32398376 Mon Sep 17 00:00:00 2001
From: "Paul W. Rankin" <rnkn%rnkn.xyz@localhost>
Date: Sun, 11 Oct 2026 19:21:14 +1100
Subject: [PATCH] inetd: allow max value of 0 to disable automatic shutdowns
---
usr.sbin/inetd/inetd.8 | 6 ++++++
usr.sbin/inetd/parse.c | 4 ++--
usr.sbin/inetd/ratelimit.c | 7 ++++++-
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/usr.sbin/inetd/inetd.8 b/usr.sbin/inetd/inetd.8
index e54ff342b..a1fa76ef3 100644
--- a/usr.sbin/inetd/inetd.8
+++ b/usr.sbin/inetd/inetd.8
@@ -343,6 +343,11 @@ within an interval of 60 seconds.
When omitted,
.Dq max
defaults to 40.
+A
+.Dq max
+of 0 disables rate limiting for the service;
+.Nm
+will then spawn an unlimited number of server instances for it.
If it reaches this maximum spawn rate,
.Nm
will log the problem (via the syslogger using the
@@ -533,6 +538,7 @@ Equivalent to
.Em max
in positional notation.
Defaults to 40 if not specified.
+A value of 0 disables rate limiting for the service.
.It Sy ip_max
Specifies the maximum number of server instances that may be spawned from
.Nm
diff --git a/usr.sbin/inetd/parse.c b/usr.sbin/inetd/parse.c
index 2ed5fe554..1484fbdc9 100644
--- a/usr.sbin/inetd/parse.c
+++ b/usr.sbin/inetd/parse.c
@@ -719,8 +719,8 @@ do { \
if (rstatus != 0) {
if (rstatus != ERANGE) {
- /* For compatibility w/ atoi parsing */
- sep->se_service_max = 0;
+ /* A value of 0 disables the rate limit. */
+ sep->se_service_max = TOOMANY;
}
WRN("Improper \"max\" value '%s', "
diff --git a/usr.sbin/inetd/ratelimit.c b/usr.sbin/inetd/ratelimit.c
index aebe95d83..788296582 100644
--- a/usr.sbin/inetd/ratelimit.c
+++ b/usr.sbin/inetd/ratelimit.c
@@ -98,7 +98,8 @@ rl_process(struct servtab *sep, int ctrl)
DPRINTF(SERV_FMT ": running service ", SERV_PARAMS(sep));
/* se_count is only incremented if rl_process will return 0 */
- sep->se_count++;
+ if (sep->se_count < SIZE_MAX)
+ sep->se_count++;
return 0;
}
@@ -349,6 +350,10 @@ rl_try_get_ip(struct servtab *sep, union addr *addr)
static bool
rl_process_service_max(struct servtab *sep, int ctrl, time_t *now)
{
+ if (sep->se_service_max == 0) {
+ /* Rate limiting disabled for this service. */
+ return true;
+ }
if (sep->se_count >= sep->se_service_max) {
if (*now == -1) {
/* Only get the clock time if we didn't already */
--
2.56.0
Home |
Main Index |
Thread Index |
Old Index