Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: rc@rexion.ai
Cc: pablo@netfilter.org, kadlec@netfilter.org, fw@strlen.de,
	phil@nwl.cc, netfilter-devel@vger.kernel.org,
	coreteam@netfilter.org, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org
Subject: Re: [PATCH nf-next v4 1/4] netfilter: conntrack: add shared uint and port parsers for helpers
Date: Sun, 27 Sep 2026 17:37:01 +0000	[thread overview]
Message-ID: <179053062118.2160803.7576370507948039473@kernel.org> (raw)
In-Reply-To: <20260923120738.2844168-1-rc@rexion.ai>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] nf_ct_helper_parse_uint() rejects any run of 12 or more digits,
  even when the value fits in UINT_MAX, and neither comment mentions…

--

netfilter: conntrack: add shared uint and port parsers for helpers

This commit adds nf_ct_helper_parse_uint() and nf_ct_helper_parse_port()
to the conntrack helper core. Both parse decimal numbers from a buffer of
a given length. The uint parser body is taken from sip_strtouint(), and
both functions are exported for the IRC, Amanda and SIP helpers.

> diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
> index c30ae3f203bee..99b90a54d8a9f 100644
> --- a/net/netfilter/nf_conntrack_helper.c
> +++ b/net/netfilter/nf_conntrack_helper.c

[ ... ]

> @@ -569,6 +570,73 @@ void nf_nat_helper_unregister(struct nf_conntrack_nat_helper *nat)
>  }
>  EXPORT_SYMBOL_GPL(nf_nat_helper_unregister);
>  
> +/* Parse a decimal unsigned integer from a length-delimited buffer that is not
> + * necessarily NUL-terminated.  At most @len bytes are examined.  On success
> + * the parsed value is returned and, if @endp is non-NULL, *@endp points just
> + * past the last digit consumed.  If no digit is found or the value would
> + * exceed UINT_MAX, 0 is returned and *@endp is set to @cp.
> + */
> +unsigned int nf_ct_helper_parse_uint(const char *cp, unsigned int len,
> +				     char **endp)
> +{
> +	const unsigned int max = sizeof("4294967295");
> +	unsigned int olen = len;
> +	const char *s = cp;
> +	u64 result = 0;
> +
> +	if (len > max)
> +		len = max;
> +
> +	while (olen > 0 && isdigit(*s)) {
> +		unsigned int value;
> +
> +		if (len == 0)
> +			goto err;

[Severity: Low]
Should a run of 12 or more digits be rejected here when the value still
fits in UINT_MAX?

max is sizeof("4294967295"), which is 11 because sizeof counts the NUL.
For longer inputs, len is clamped to 11 while olen keeps the real length.

The loop condition only checks olen and isdigit(). So a 12th digit enters
the loop and finds len == 0. It then takes the err path, which returns 0
and sets *endp to cp.

With leading zeros, result stays small, so this failure comes only from
the digit count. The count limit does not seem to add overflow
protection. result is a u64 and is compared against UINT_MAX after every
digit.

The comment above lists only "no digit is found" and "exceed UINT_MAX" as
failure cases. The nf_ct_helper_parse_port() comment lists only "no digit
is found" and "out of range".

nf_ct_helper_parse_port() treats e == cp as a failure:

	val = nf_ct_helper_parse_uint(cp, len, &e);
	if (e == cp || val == 0 || val > 65535)
		return -1;

So an input like "000000000080" returns -1 there.

This logic came from sip_strtouint(), but it is now a general exported
API. Later in the series, "netfilter: nf_conntrack_irc: use
nf_ct_helper_parse_port()" replaces simple_strtoul() in parse_dcc().
simple_strtoul() accepted any number of leading zeros.

Would a DCC command such as "DCC SEND f <ip> 0000000000006667" then fail
to parse, so that no expectation is created for it?

Amanda does not look affected, because pbuf limits its input to 5
characters.

Could the digit-count limit be dropped, or else documented in both
comments?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260923091608.2617604-1-rc%40rexion.ai

  reply	other threads:[~2026-09-27 17:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23  9:16 [PATCH nf-next v4 0/4] netfilter: conntrack: shared port parser for helpers Rahul Chandelkar
2026-09-23 12:07 ` [PATCH nf-next v4 1/4] netfilter: conntrack: add shared uint and port parsers " Rahul Chandelkar
2026-09-27 17:37   ` netdev-bot+sashiko [this message]
2026-09-28 14:18     ` Rahul Chandelkar
2026-09-23 13:15 ` [PATCH nf-next v4 2/4] netfilter: nf_conntrack_irc: use nf_ct_helper_parse_port() Rahul Chandelkar
2026-09-27 17:37   ` netdev-bot+sashiko
2026-09-28 15:23     ` Rahul Chandelkar
2026-09-23 15:15 ` [PATCH nf-next v4 3/4] netfilter: nf_conntrack_amanda: " Rahul Chandelkar
2026-09-27 17:37   ` netdev-bot+sashiko
2026-09-28 11:58     ` Rahul Chandelkar
2026-09-23 17:15 ` [PATCH nf-next v4 4/4] netfilter: nf_conntrack_sip: use shared helper parsers Rahul Chandelkar
2026-09-27 17:37   ` netdev-bot+sashiko
2026-09-28 13:13     ` Rahul Chandelkar

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=179053062118.2160803.7576370507948039473@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=kadlec@netfilter.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=phil@nwl.cc \
    --cc=rc@rexion.ai \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox