From: Kevin Cernekee <cernekee@chromium.org>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC/PATCH 1/3] netfilter: ctnetlink: Fix regression in CTA_TIMEOUT processing
Date: Mon, 16 Jan 2017 21:14:06 -0800 [thread overview]
Message-ID: <1484630048-25416-2-git-send-email-cernekee@chromium.org> (raw)
In-Reply-To: <1484630048-25416-1-git-send-email-cernekee@chromium.org>
Commit b7bd1809e078 ("netfilter: nfnetlink_queue: get rid of
nfnetlink_queue_ct.c") introduced a new check on the return value
from the NFQA_CT parser (currently ctnetlink_glue_parse_ct()).
Prior to Linux 4.4, nfqnl_ct_parse() would process the NFQA_EXP
attribute even if there were errors in the NFQA_CT attribute.
After Linux 4.4, this is no longer true, so any error in the NFQA_CT
attribute will cause the kernel to silently fail to create an
expectation.
The new check is causing user conntrack helpers to fail. If a user
program sends an NFQA_CT attribute containing a CTA_TIMEOUT attribute
before the connection is confirmed (i.e. before the initial
ACCEPT/DROP decision has been made), del_timer() in
ctnetlink_change_timeout() will fail, and all further processing will be
aborted. The (simplified) calling sequence looks like:
nfnetlink_rcv_msg
nfqnl_recv_verdict
nfqnl_ct_parse
ctnetlink_glue_parse_ct
ctnetlink_change_timeout
del_timer [ERROR]
nf_reinject
__nf_conntrack_confirm
Fix this by adding a case to ctnetlink_change_timeout() to handle
unconfirmed connections.
Also, if a timeout of 0 is set for an unconfirmed connection, restore the
old behavior of ignoring it (rather than setting up a connection that
expires immediately).
Signed-off-by: Kevin Cernekee <cernekee@chromium.org>
---
net/netfilter/nf_conntrack_netlink.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 9f5272968abb..43beb950df16 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1531,11 +1531,15 @@ ctnetlink_change_timeout(struct nf_conn *ct, const struct nlattr * const cda[])
{
u_int32_t timeout = ntohl(nla_get_be32(cda[CTA_TIMEOUT]));
- if (!del_timer(&ct->timeout))
- return -ETIME;
+ if (nf_ct_is_confirmed(ct)) {
+ if (!del_timer(&ct->timeout))
+ return -ETIME;
- ct->timeout.expires = jiffies + timeout * HZ;
- add_timer(&ct->timeout);
+ ct->timeout.expires = jiffies + timeout * HZ;
+ add_timer(&ct->timeout);
+ } else if (timeout != 0) {
+ ct->timeout.expires = timeout * HZ;
+ }
return 0;
}
--
2.7.4
next prev parent reply other threads:[~2017-01-17 5:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-17 5:14 [RFC/PATCH 0/3] Fix ctnetlink regressions Kevin Cernekee
2017-01-17 5:14 ` Kevin Cernekee [this message]
2017-01-18 18:54 ` [RFC/PATCH 1/3] netfilter: ctnetlink: Fix regression in CTA_TIMEOUT processing Doug Anderson
2017-01-17 5:14 ` [RFC/PATCH 2/3] netfilter: ctnetlink: Fix regression in CTA_STATUS processing Kevin Cernekee
2017-01-18 19:02 ` Doug Anderson
2017-01-17 5:14 ` [RFC/PATCH 3/3] netfilter: ctnetlink: Fix regression in CTA_HELP processing Kevin Cernekee
2017-01-18 19:08 ` Doug Anderson
2017-01-25 0:36 ` [RFC/PATCH 0/3] Fix ctnetlink regressions 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=1484630048-25416-2-git-send-email-cernekee@chromium.org \
--to=cernekee@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--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 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).