All of lore.kernel.org
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org, davem@davemloft.net,
	netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com,
	edumazet@kernel.org, horms@kernel.org, fw@strlen.de, ja@ssi.bg
Subject: Re: [PATCH net 08/10] netfilter: xt_dccp: handle reserved options as single-byte
Date: Tue, 20 Oct 2026 15:38:06 +0000	[thread overview]
Message-ID: <179251068646.3135.16276902372052104830@kernel.org> (raw)
In-Reply-To: <20261019150249.1879516-9-pablo@netfilter.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0 (1)

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The commit message lists CONFIG_NETFILTER_XTABLES_LEGACY as a
  prerequisite for the bug.

Pre-existing issues:
- [Low] This problem wasn't introduced by this patch, but
  dccp_find_option() in net/netfilter/xt_dccp.c does not validate multi-…

--

netfilter: xt_dccp: handle reserved options as single-byte

This commit changes dccp_find_option() so that every DCCP option number
up to DCCPO_MAX_RESERVED is treated as a single-byte option. Before, only
Padding and Mandatory were. The old behaviour read the byte after a
reserved option as a TLV length, which could skip a later option and
invert an XT_DCCP_OPTION rule result.

> Treat every option up to DCCPO_MAX_RESERVED as single-byte, matching the
> protocol definition.  Triggering requires
> CONFIG_NETFILTER_XTABLES_LEGACY, CONFIG_NETFILTER_XT_MATCH_DCCP, an
> option-based rule, and remote protocol-33 reachability.

[Severity: Medium]
Is CONFIG_NETFILTER_XTABLES_LEGACY actually needed to trigger this?

In net/netfilter/Kconfig, NETFILTER_XT_MATCH_DCCP sits inside the
if NETFILTER_XTABLES block and depends only on NETFILTER_ADVANCED:

config NETFILTER_XT_MATCH_DCCP
	tristate '"dccp" protocol match support (DEPRECATED)'
	depends on NETFILTER_ADVANCED

NFT_COMPAT depends only on NETFILTER_XTABLES:

config NFT_COMPAT
	depends on NETFILTER_XTABLES

nft_match_select_ops() in net/netfilter/nft_compat.c looks up the
registered "dccp" match by name:

	match = xt_request_find_match(family, mt_name, rev);

The nft_compat packet path then reaches the same parser:

__nft_match_eval()
  match->match(skb, &xt)
    dccp_mt()
      match_option()
        dccp_find_option()

So iptables-nft setups without legacy tables support seem to have the
same reserved-option bypass. The fix in the shared helper covers both
frontends. Only the stated trigger conditions look wrong.

Could the commit message drop CONFIG_NETFILTER_XTABLES_LEGACY from the
prerequisites, or list CONFIG_NFT_COMPAT as an alternative? That way
backport and security triage won't skip nft-based systems.

> diff --git a/net/netfilter/xt_dccp.c b/net/netfilter/xt_dccp.c
> index 3db81e041af9..23a4e3e8df7d 100644
> --- a/net/netfilter/xt_dccp.c
> +++ b/net/netfilter/xt_dccp.c
> @@ -62,7 +62,7 @@ dccp_find_option(u_int8_t option,
>  			return true;
>  		}
>  
> -		if (op[i] < 2 || i == optlen - 1)
> +		if (op[i] <= DCCPO_MAX_RESERVED || i == optlen - 1)
>  			i++;
>  		else
>  			i += op[i + 1] ? : 1;

[Severity: Low]
This isn't a bug introduced by this patch, but should dccp_find_option()
also reject multi-byte option lengths below 2?

For a type of 32 or above, a length byte of 0 or 1 moves i forward by one
byte. The next loop iteration then reads the length byte as an option
type.

For example, with options {32, 1, 0, 0} and --dccp-option 1:

  i = 0: op[0] == 32, no match, i += op[1] (1)
  i = 1: op[1] == 1, matches, returns true

No Mandatory option is actually present here. A {32, 0, ...} sequence
gives a phantom match for option 0 the same way.

nft_exthdr_dccp_eval() in net/netfilter/nft_exthdr.c parses the same
option space. It stops with no match on such lengths:

	if (buflen < 2)
		goto err;

	len = bufp[1];

	if (len < 2)
		goto err;

So xt_dccp and nft exthdr dccp still give different answers for the same
malformed packet. Since the length byte is below 2, the phantom match
can only be option type 0 or 1. This patch brings the single-byte
classification in line with nft_exthdr but leaves this length check
difference in place.

Would it make sense to stop parsing (or treat it as no match) when
op[i + 1] < 2, as nft_exthdr_dccp_eval() does?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261019150249.1879516-2-pablo%40netfilter.org

  reply	other threads:[~2026-10-20 15:38 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 15:02 [PATCH net 00/10] Netfilter/IPVS fixes for net Pablo Neira Ayuso
2026-10-19 15:02 ` [PATCH net 01/10] netfilter: nf_conntrack: avoid truncating IPv6 nexthdr offset Pablo Neira Ayuso
2026-10-19 15:55   ` netdev-bot+sinfo
2026-10-21  2:10   ` patchwork-bot+netdevbpf
2026-10-19 15:02 ` [PATCH net 02/10] netfilter: nft_payload: restrict checksum offsets to known values Pablo Neira Ayuso
2026-10-20 15:36   ` netdev-bot+sashiko
2026-10-19 15:02 ` [PATCH net 03/10] ipvs: fix more races around the overload flag Pablo Neira Ayuso
2026-10-20 15:36   ` netdev-bot+sashiko
2026-10-20 22:06     ` Pablo Neira Ayuso
2026-10-19 15:02 ` [PATCH net 04/10] ipvs: skip committing sync_threshold when proc_dointvec fails Pablo Neira Ayuso
2026-10-20 15:37   ` netdev-bot+sashiko
2026-10-19 15:02 ` [PATCH net 05/10] netfilter: flowtable: use the vlan id, not the full tci, in the tuple key Pablo Neira Ayuso
2026-10-19 15:02 ` [PATCH net 06/10] netfilter: nf_reject: initialize IPCB at inet ingress Pablo Neira Ayuso
2026-10-20 15:37   ` netdev-bot+sashiko
2026-10-20 22:01     ` Pablo Neira Ayuso
2026-10-19 15:02 ` [PATCH net 07/10] netfilter: nft_set_rbtree: narrow down range completion to anonymous sets Pablo Neira Ayuso
2026-10-19 15:02 ` [PATCH net 08/10] netfilter: xt_dccp: handle reserved options as single-byte Pablo Neira Ayuso
2026-10-20 15:38   ` netdev-bot+sashiko [this message]
2026-10-19 15:02 ` [PATCH net 09/10] netfilter: flowtable: reset transport header after nf_flow_encap_pop() Pablo Neira Ayuso
2026-10-19 15:02 ` [PATCH net 10/10] netfilter: nf_conntrack_netlink: fix inverted IPv6 tuple filter Pablo Neira Ayuso
2026-10-20 15:38   ` netdev-bot+sashiko
2026-10-20 21:10 ` [PATCH net 00/10] Netfilter/IPVS fixes for net Jakub Kicinski
2026-10-20 21:36   ` Pablo Neira Ayuso

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=179251068646.3135.16276902372052104830@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=ja@ssi.bg \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.