All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: luoqing <l1138897701@163.com>
Cc: Florian Westphal <fw@strlen.de>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Phil Sutter <phil@nwl.cc>, Simon Horman <horms@kernel.org>,
	Jing Min Zhao <zhaojignmin@hotmail.com>,
	Patrick McHardy <kaber@trash.net>,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] netfilter: nf_conntrack_h323: fix double cursor advance in decode_int()
Date: Fri, 21 Aug 2026 13:00:13 +0200	[thread overview]
Message-ID: <aogvvRZuH8j650Oj@chamomile> (raw)
In-Reply-To: <20260821065229.121871-1-l1138897701@163.com>

On Fri, Aug 21, 2026 at 02:52:29PM +0800, luoqing wrote:
> From: Qing Luo <luoqing@kylinos.cn>
> 
> In the CONS case of decode_int(), when the field is actually decoded
> (base is not NULL and the field carries the DECODE attribute),
> get_uint() already advances the bitstream cursor by 'len' bytes.  The
> subsequent unconditional "bs->cur += len" then advances the cursor a
> second time over the same data, so the parser skips 'len' extra bytes.
> 
> All fields following such an integer are decoded from a wrong bit
> position.  This affects the timeToLive field in RAS
> RegistrationRequest/RegistrationConfirm messages: subsequent fields
> (e.g. transport addresses) end up being parsed from arbitrary offsets
> inside the message, so the helper may create expectations based on
> bogus addresses/ports.
> 
> Only advance the cursor manually when get_uint() was not called, so
> that the value bytes are consumed exactly once in either case.

This patch should be targeted at nf-next.

Please, use [PATCH nf-next] given this does not result in a crash.

> Fixes: 5e35941d9901 ("[NETFILTER]: Add H.323 conntrack/NAT helper")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Qing Luo <luoqing@kylinos.cn>
> ---
>  net/netfilter/nf_conntrack_h323_asn1.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/netfilter/nf_conntrack_h323_asn1.c b/net/netfilter/nf_conntrack_h323_asn1.c
> index 6830c9da3507..a51275cc4d0f 100644
> --- a/net/netfilter/nf_conntrack_h323_asn1.c
> +++ b/net/netfilter/nf_conntrack_h323_asn1.c
> @@ -336,8 +336,9 @@ static int decode_int(struct bitstr *bs, const struct field_t *f,
>  			unsigned int v = get_uint(bs, len) + f->lb;
>  			PRINT(" = %u", v);
>  			*((unsigned int *)(base + f->offset)) = v;
> +		} else {
> +			bs->cur += len;
>  		}
> -		bs->cur += len;
>  		break;
>  	case UNCO:
>  		BYTE_ALIGN(bs);
> -- 
> 2.25.1
> 

      reply	other threads:[~2026-08-21 11:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21  6:52 [PATCH net] netfilter: nf_conntrack_h323: fix double cursor advance in decode_int() luoqing
2026-08-21 11:00 ` Pablo Neira Ayuso [this message]

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=aogvvRZuH8j650Oj@chamomile \
    --to=pablo@netfilter.org \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=kaber@trash.net \
    --cc=kuba@kernel.org \
    --cc=l1138897701@163.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=phil@nwl.cc \
    --cc=zhaojignmin@hotmail.com \
    /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.