Re: [PATCH nf] x_tables: Properly close read section with read_seqcount_retry

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Will Deacon <will@xxxxxxxxxx> wrote:
> > diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
> > index af22dbe85e2c..b5911985d1eb 100644
> > --- a/net/netfilter/x_tables.c
> > +++ b/net/netfilter/x_tables.c
> > @@ -1384,7 +1384,7 @@ xt_replace_table(struct xt_table *table,
> >          * private.
> >          */
> >         smp_wmb();
> > -       table->private = newinfo;
> > +       WRITE_ONCE(table->private, newinfo);
> 
> ... you could make this rcu_assign_pointer() and get rid of the preceding
> smp_wmb()...

Yes, it would make sense to add proper rcu annotation as well.

> >         /* make sure all cpus see new ->private value */
> >         smp_wmb();
> 
> ... and this smp_wmb() is no longer needed because synchronize_rcu()
> takes care of the ordering.

Right, thanks.

> > @@ -1394,19 +1394,7 @@ xt_replace_table(struct xt_table *table,
> >          * may still be using the old entries...
> >          */
> >         local_bh_enable();
> > -
> > -       /* ... so wait for even xt_recseq on all cpus */
> > -       for_each_possible_cpu(cpu) {
> > -               seqcount_t *s = &per_cpu(xt_recseq, cpu);
> > -               u32 seq = raw_read_seqcount(s);
> > -
> > -               if (seq & 1) {
> > -                       do {
> > -                               cond_resched();
> > -                               cpu_relax();
> > -                       } while (seq == raw_read_seqcount(s));
> > -               }
> > -       }
> 
> Do we still need xt_write_recseq_{begin,end}() with this removed?

Yes, it enables userspace to get stable per rule packet and byte counters.



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux