From: Pablo Neira Ayuso <pablo@netfilter.org>
To: zhang kai <zhangkaiheb@126.com>
Cc: kadlec@netfilter.org, fw@strlen.de, davem@davemloft.net,
kuba@kernel.org, netfilter-devel@vger.kernel.org,
coreteam@netfilter.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] netfilter: seqadj: check seq offset before update
Date: Thu, 6 Jan 2022 22:53:45 +0100 [thread overview]
Message-ID: <Yddk6YFEJ/FOWYT3@salvia> (raw)
In-Reply-To: <20211224023713.9260-1-zhangkaiheb@126.com>
On Fri, Dec 24, 2021 at 10:37:13AM +0800, zhang kai wrote:
> if seq/ack offset is zero, don't update
Please, provide more details: explain the scenario that triggers and
seq/ack offset adjustment of zero, describe the scenario that triggers
the bug, etc.
> Signed-off-by: zhang kai <zhangkaiheb@126.com>
> ---
> net/netfilter/nf_conntrack_seqadj.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/net/netfilter/nf_conntrack_seqadj.c b/net/netfilter/nf_conntrack_seqadj.c
> index 3066449f8bd8..d35e272a2e36 100644
> --- a/net/netfilter/nf_conntrack_seqadj.c
> +++ b/net/netfilter/nf_conntrack_seqadj.c
> @@ -186,11 +186,13 @@ int nf_ct_seq_adjust(struct sk_buff *skb,
> else
> seqoff = this_way->offset_before;
>
> - newseq = htonl(ntohl(tcph->seq) + seqoff);
> - inet_proto_csum_replace4(&tcph->check, skb, tcph->seq, newseq, false);
> - pr_debug("Adjusting sequence number from %u->%u\n",
> - ntohl(tcph->seq), ntohl(newseq));
> - tcph->seq = newseq;
> + if (seqoff) {
> + newseq = htonl(ntohl(tcph->seq) + seqoff);
> + inet_proto_csum_replace4(&tcph->check, skb, tcph->seq, newseq, false);
> + pr_debug("Adjusting sequence number from %u->%u\n",
> + ntohl(tcph->seq), ntohl(newseq));
> + tcph->seq = newseq;
> + }
>
> if (!tcph->ack)
> goto out;
> @@ -201,6 +203,9 @@ int nf_ct_seq_adjust(struct sk_buff *skb,
> else
> ackoff = other_way->offset_before;
>
> + if (!ackoff)
> + goto out;
> +
> newack = htonl(ntohl(tcph->ack_seq) - ackoff);
> inet_proto_csum_replace4(&tcph->check, skb, tcph->ack_seq, newack,
> false);
> --
> 2.17.1
>
prev parent reply other threads:[~2022-01-06 21:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-24 2:37 [PATCH] netfilter: seqadj: check seq offset before update zhang kai
2022-01-06 21:53 ` 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=Yddk6YFEJ/FOWYT3@salvia \
--to=pablo@netfilter.org \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=fw@strlen.de \
--cc=kadlec@netfilter.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=zhangkaiheb@126.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).