Netdev List
 help / color / mirror / Atom feed
* [PATCH nf-next v5 0/4] netfilter: conntrack: shared port parser for helpers
@ 2026-09-28 16:28 Rahul Chandelkar
  2026-09-28 17:33 ` [PATCH nf-next v5 1/4] netfilter: conntrack: add shared uint and port parsers " Rahul Chandelkar
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Rahul Chandelkar @ 2026-09-28 16:28 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: Jozsef Kadlecsik, Florian Westphal, Phil Sutter, netfilter-devel,
	coreteam, davem, edumazet, kuba, pabeni, netdev, Rahul Chandelkar

The IRC and Amanda conntrack helpers parse port numbers from packet
payload with simple_strtoul(), which returns unsigned long without a
range check, so a port above 65535 is truncated when it is stored in a
u16 (65537 becomes 1) and an expectation is created for a port that
never appeared in the payload.  Amanda also cuts a port field of six or
more digits down to its first five.  Both problems are present in
current nf-next.

Instead of open-coding a range check in each helper, this series moves
the sip_strtouint() parser of nf_conntrack_sip into the helper core as
nf_ct_helper_parse_uint(), adds nf_ct_helper_parse_port() on top of it,
and converts the three helpers:

  1/4 adds the two parsers
  2/4 and 3/4 fix the IRC and Amanda helpers
  4/4 removes the now duplicate parsing code from the SIP helper
      (no functional change)

Testing: allmodconfig and allyesconfig builds with W=1, sparse, an
allnoconfig build, i386 and big-endian powerpc cross-builds, and a
build of each patch in turn.  The old and new sip_parse_port() were
compared in a userspace harness built from the kernel source on three
million random inputs with no difference.  The helpers have not been
run-time tested with IRC, Amanda or SIP traffic.

Tool use: v4 and v5 were prepared with Claude Code, an AI coding
assistant, as recorded in the Assisted-by tags.  It wrote most of the
code changes and changelogs from v3 and the review feedback, and ran
the builds and tests listed above.  v4 should have carried the tags as
well; it did not, sorry about that.

Changes in v5:
  - nf_ct_helper_parse_port(): reject digit runs longer than five
    characters, so that sip_parse_port() still rejects zero-padded
    ports and 4/4 has no functional change; return -EINVAL rather
    than -1
  - add kernel-doc for both parsers, including their digit limits
  - amanda: make pbuf one byte larger so that a port field of six or
    more digits is rejected instead of being cut to its first five
    digits
  - irc: remove the dcc_port == 0 test in help(), which can no longer
    be true
  - sip: rewrap call sites that no longer fit in 80 columns
  - add Assisted-by tags
  (the first four items address the Sashiko review of v4)
v4: https://lore.kernel.org/all/20260923091608.2617604-1-rc@rexion.ai/
  - rebase onto nf-next; move sip_strtouint() into the helper core
    instead of adding a second parser, and convert nf_conntrack_sip
    (Pablo Neira Ayuso, Phil Sutter, Florian Westphal)
  - use a real name and target nf-next (Pablo Neira Ayuso)
v3: https://lore.kernel.org/all/20260503083220.630655-1-rc@rexion.ai/
  - add nf_ct_helper_parse_uint() and convert nf_conntrack_sip
    (Phil Sutter)
v2: https://lore.kernel.org/all/20260501063156.2520780-1-rc@rexion.ai/
  - add a shared nf_ct_helper_parse_port() in the helper core instead
    of open-coding range checks (Florian Westphal, Pablo Neira Ayuso)
v1: https://lore.kernel.org/all/20260430161230.3438973-1-rc@rexion.ai/

Rahul Chandelkar (4):
  netfilter: conntrack: add shared uint and port parsers for helpers
  netfilter: nf_conntrack_irc: use nf_ct_helper_parse_port()
  netfilter: nf_conntrack_amanda: use nf_ct_helper_parse_port()
  netfilter: nf_conntrack_sip: use shared helper parsers

 include/net/netfilter/nf_conntrack_helper.h |  5 ++
 net/netfilter/nf_conntrack_amanda.c         | 13 ++-
 net/netfilter/nf_conntrack_helper.c         | 79 +++++++++++++++++
 net/netfilter/nf_conntrack_irc.c            |  9 +-
 net/netfilter/nf_conntrack_sip.c            | 93 ++++++---------------
 5 files changed, 123 insertions(+), 76 deletions(-)


base-commit: 87b80c2f6b05cad9f0ff9136709c62a0f59923e3
-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-09-30  9:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-28 16:28 [PATCH nf-next v5 0/4] netfilter: conntrack: shared port parser for helpers Rahul Chandelkar
2026-09-28 17:33 ` [PATCH nf-next v5 1/4] netfilter: conntrack: add shared uint and port parsers " Rahul Chandelkar
2026-09-28 18:39 ` [PATCH nf-next v5 2/4] netfilter: nf_conntrack_irc: use nf_ct_helper_parse_port() Rahul Chandelkar
2026-09-28 19:44 ` [PATCH nf-next v5 3/4] netfilter: nf_conntrack_amanda: " Rahul Chandelkar
2026-09-28 20:49 ` [PATCH nf-next v5 4/4] netfilter: nf_conntrack_sip: use shared helper parsers Rahul Chandelkar
2026-09-28 20:56 ` [PATCH nf-next v5 0/4] netfilter: conntrack: shared port parser for helpers netdev-bot+sinfo
2026-09-30  9:57   ` Rahul Chandelkar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox