netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nf 0/4] netfilter: ctnetlink: fix some bugs related to ct update
@ 2017-04-17 13:18 Liping Zhang
  2017-04-17 13:18 ` [PATCH nf 1/4] netfilter: ctnetlink: drop the incorrect cthelper module request Liping Zhang
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Liping Zhang @ 2017-04-17 13:18 UTC (permalink / raw)
  To: pablo; +Cc: netfilter-devel, Liping Zhang

From: Liping Zhang <zlpnobody@gmail.com>

This patch set aims to fix some bugs related to ctnetlink_change_conntrack.

First, we may invoke request_module with rcu_read_lock held, this is wrong,
as the request_module invocation may sleep. Fixed by PATCH #1.

Second, the unnecessary nf_conntrack_expect_lock will cause dead lock, which
was introduced by commit ca7433df3a67 ("netfilter: conntrack: seperate expect
locking from nf_conntrack_lock"). This is fixed by PATCH #2.

Third, Pablo pointed out that packets may be updating a conntrack at the
same time that we're mangling via ctnetlink, it's better to fix the
possible race together. So I audited the related source codes as follows:
1. CTA_HELP: for the userspace cthelper, no problem; for the inkernel
             cthelper, there's only one user: nf_ct_ftp_from_nlattr,
             but it only sets two flags, so no problem too.
2. CTA_TIMEOUT: only modify the ct->timeout, so no problem
3. CTA_STATUS: possible race will happen, fixed by PATCH #3
4. CTA_PROTOINFO: protected by ct->lock, no problem
5. CTA_MARK: only modify the ct->mark, no problem
6. CTA_SEQ_ADJ_X: should be protectd by ct->lock, fixed by PATCH #4
7. CTA_LABELS: use cmpxchg to update labels, so no problem

Liping Zhang (4):
  netfilter: ctnetlink: drop the incorrect cthelper module request
  netfilter: ctnetlink: fix deadlock due to acquire _expect_lock twice
  netfilter: ctnetlink: make it safer when updating ct->status
  netfilter: ctnetlink: acquire ct->lock before operating nf_ct_seqadj

 include/uapi/linux/netfilter/nf_conntrack_common.h | 13 +++-
 net/netfilter/nf_conntrack_netlink.c               | 89 ++++++++++++----------
 2 files changed, 58 insertions(+), 44 deletions(-)

-- 
2.5.5



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-04-25  9:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-17 13:18 [PATCH nf 0/4] netfilter: ctnetlink: fix some bugs related to ct update Liping Zhang
2017-04-17 13:18 ` [PATCH nf 1/4] netfilter: ctnetlink: drop the incorrect cthelper module request Liping Zhang
2017-04-17 13:18 ` [PATCH nf 2/4] netfilter: ctnetlink: fix deadlock due to acquire _expect_lock twice Liping Zhang
2017-04-17 13:18 ` [PATCH nf 3/4] netfilter: ctnetlink: make it safer when updating ct->status Liping Zhang
2017-04-17 13:18 ` [PATCH nf 4/4] netfilter: ctnetlink: acquire ct->lock before operating nf_ct_seqadj Liping Zhang
2017-04-25  9:07 ` [PATCH nf 0/4] netfilter: ctnetlink: fix some bugs related to ct update Pablo Neira Ayuso

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).