Linux Netfilter development
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Tzung-Bi Shih <tzungbi@kernel.org>
Cc: kadlec@netfilter.org, fw@strlen.de,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	jiejiang@chromium.org, jasongustaman@chromium.org,
	garrick@chromium.org
Subject: Re: [PATCH] netfilter: conntrack: fix wrong ct->timeout value
Date: Mon, 10 Apr 2023 11:31:21 +0200	[thread overview]
Message-ID: <ZDPXad/8beRw78yX@calendula> (raw)
In-Reply-To: <ZDPJ2rHi5fOqu4ga@calendula>

[-- Attachment #1: Type: text/plain, Size: 690 bytes --]

On Mon, Apr 10, 2023 at 10:33:32AM +0200, Pablo Neira Ayuso wrote:
> Hi,
> 
> On Mon, Apr 10, 2023 at 02:09:35PM +0800, Tzung-Bi Shih wrote:
> > (struct nf_conn)->timeout is an interval before the conntrack
> > confirmed.  After confirmed, it becomes a timestamp[1].
> > 
> > It is observed that timeout of an unconfirmed conntrack have been
> > altered by calling ctnetlink_change_timeout().  As a result,
> > `nfct_time_stamp` was wrongly added to `ct->timeout` twice[2].
> > 
> > Differentiate the 2 cases in all `ct->timeout` accesses.
> 
> You can just skip refreshing the timeout for unconfirmed conntrack
> entries in ctnetlink_change_timeout().

Something like this patch probably?

[-- Attachment #2: x.patch --]
[-- Type: text/x-diff, Size: 596 bytes --]

diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index bfc3aaa2c872..6556f5f30844 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -2466,7 +2466,8 @@ static int ctnetlink_new_conntrack(struct sk_buff *skb,
 
 	err = -EEXIST;
 	ct = nf_ct_tuplehash_to_ctrack(h);
-	if (!(info->nlh->nlmsg_flags & NLM_F_EXCL)) {
+	if (!(info->nlh->nlmsg_flags & NLM_F_EXCL) &&
+	    nf_ct_is_confirmed(ct)) {
 		err = ctnetlink_change_conntrack(ct, cda);
 		if (err == 0) {
 			nf_conntrack_eventmask_report((1 << IPCT_REPLY) |

  reply	other threads:[~2023-04-10  9:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-10  6:09 [PATCH] netfilter: conntrack: fix wrong ct->timeout value Tzung-Bi Shih
2023-04-10  8:33 ` Pablo Neira Ayuso
2023-04-10  9:31   ` Pablo Neira Ayuso [this message]
2023-04-10  9:59     ` Tzung-Bi Shih
2023-04-12 22:56       ` Pablo Neira Ayuso
2023-04-13  3:23         ` Tzung-Bi Shih
2023-04-13  9:04           ` Pablo Neira Ayuso
2023-04-14  3:52             ` Tzung-Bi Shih
2023-04-14  8:12               ` Pablo Neira Ayuso
2023-04-17  3:41                 ` Tzung-Bi Shih
2023-04-18  8:17                   ` Pablo Neira Ayuso
2023-04-19  5:20                     ` Tzung-Bi Shih

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=ZDPXad/8beRw78yX@calendula \
    --to=pablo@netfilter.org \
    --cc=coreteam@netfilter.org \
    --cc=fw@strlen.de \
    --cc=garrick@chromium.org \
    --cc=jasongustaman@chromium.org \
    --cc=jiejiang@chromium.org \
    --cc=kadlec@netfilter.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=tzungbi@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox