Files
android_kernel_xiaomi_sm8450/include/uapi/linux
Liping Zhang 53b56da83d netfilter: ctnetlink: make it safer when updating ct->status
After converting to use rcu for conntrack hash, one CPU may update
the ct->status via ctnetlink, while another CPU may process the
packets and update the ct->status.

So the non-atomic operation "ct->status |= status;" via ctnetlink
becomes unsafe, and this may clear the IPS_DYING_BIT bit set by
another CPU unexpectedly. For example:
         CPU0                            CPU1
  ctnetlink_change_status        __nf_conntrack_find_get
      old = ct->status              nf_ct_gc_expired
          -                         nf_ct_kill
          -                      test_and_set_bit(IPS_DYING_BIT
      new = old | status;                 -
  ct->status = new; <-- oops, _DYING_ is cleared!

Now using a series of atomic bit operation to solve the above issue.

Also note, user shouldn't set IPS_TEMPLATE, IPS_SEQ_ADJUST directly,
so make these two bits be unchangable too.

If we set the IPS_TEMPLATE_BIT, ct will be freed by nf_ct_tmpl_free,
but actually it is alloced by nf_conntrack_alloc.
If we set the IPS_SEQ_ADJUST_BIT, this may cause the NULL pointer
deference, as the nfct_seqadj(ct) maybe NULL.

Last, add some comments to describe the logic change due to the
commit a963d710f3 ("netfilter: ctnetlink: Fix regression in CTA_STATUS
processing"), which makes me feel a little confusing.

Fixes: 76507f69c4 ("[NETFILTER]: nf_conntrack: use RCU for conntrack hash")
Signed-off-by: Liping Zhang <zlpnobody@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2017-04-24 20:06:28 +02:00
..
2014-09-23 23:15:46 -07:00
2017-01-05 13:02:25 +00:00
2016-11-29 09:00:30 +01:00
2016-10-18 10:05:42 -06:00
2014-07-01 10:48:05 -06:00
2014-03-20 14:55:18 +01:00
2015-08-25 14:41:50 -05:00
2014-11-19 14:48:02 -06:00
2016-01-20 17:09:18 -08:00
2015-04-12 21:25:13 -04:00
2016-10-01 07:32:32 +02:00
2015-12-14 12:19:37 -06:00
2013-12-11 12:57:55 -08:00
2017-01-10 14:05:11 -05:00
2017-02-03 15:16:45 -05:00
2016-11-03 15:41:11 -04:00
2016-11-03 15:41:11 -04:00
2014-12-02 13:52:53 -07:00
2016-03-22 15:36:02 -07:00
2016-06-27 16:31:25 +01:00
2016-04-12 19:54:58 +01:00
2015-08-03 17:30:00 -07:00
2014-08-08 15:57:31 -07:00
2015-07-21 10:39:05 -07:00
2017-01-17 14:38:43 -05:00
2015-01-20 13:51:06 +01:00
2014-12-13 12:42:52 -08:00
2017-02-20 11:13:37 -05:00
2015-04-23 15:16:14 -04:00
2015-07-20 14:58:46 -04:00
2017-02-09 15:17:30 +01:00
2016-05-17 17:14:21 -06:00
2017-02-09 22:59:34 -05:00
2017-02-15 11:56:07 -06:00
2017-02-17 12:08:05 -05:00
2016-09-27 21:52:00 -04:00
2016-09-27 21:52:00 -04:00
2015-09-04 16:54:41 -07:00
2016-05-08 23:46:14 -04:00
2016-04-26 12:00:48 -04:00
2017-02-20 11:13:37 -05:00
2017-01-09 16:07:38 -05:00
2016-04-04 22:11:20 -04:00
2017-01-29 19:17:23 -05:00
2014-12-09 14:10:41 +08:00
2017-01-10 18:31:55 -08:00
2015-06-11 23:37:37 +02:00
2015-12-18 17:48:51 -08:00
2015-10-27 18:55:31 -07:00
2016-05-20 17:58:30 -07:00
2016-11-17 08:33:20 -07:00
2016-12-16 00:13:38 +02:00
2016-12-16 00:13:32 +02:00
2015-03-29 12:13:52 +10:30
2016-04-30 09:26:55 -07:00