Re: [PATCH nf 1/3] netfilter: conntrack: fix race between nf_conntrack proc read and hash resize

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

 



>Good catch, but ...
>
>> diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h
>> index 3e2f332..4f6453a 100644
>> --- a/include/net/netfilter/nf_conntrack_core.h
>> +++ b/include/net/netfilter/nf_conntrack_core.h
>> @@ -82,6 +82,7 @@ print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
>>  #define CONNTRACK_LOCKS 1024
>>  
>>  extern struct hlist_nulls_head *nf_conntrack_hash;
>> +extern seqcount_t nf_conntrack_generation;
>
>instead of this and the proliferation of this:
>
>> +	do {
>> +		sequence = read_seqcount_begin(&nf_conntrack_generation);
>> +		st->htable_size = nf_conntrack_htable_size;
>> +		st->hash = nf_conntrack_hash;
>> +	} while (read_seqcount_retry(&nf_conntrack_generation, sequence));
>> +
>>  	return ct_get_idx(seq, *pos);
>>  }
>
>I think it might be better to do something like
>
>/* must be called with rcu read lock held */
>unsigned int nf_conntrack_get_ht(struct hlist_nulls_head *h,
>			         unsigned int *buckets)
>{
>	do {
>		s = read_seq ...
>		size = nf_conntrack_htable_size;
>		ptr = nf_conntrack_hash;
>	} while ...
>
>	*h = ptr;
>	*buckets = size;
>
>	return s;

Agree.

And I also find there's no need to use nf_conntrack_generation in my patch #2 and #3.
Will send V2 later.

Thanks?韬{.n?壏煯壄?%娝?檩?w?{.n?壏租栕庄z_鉃豝n噐■?侂h櫒璀?{鄗夸z罐楘+€?zf"穐殘啳嗃i?飦?戧鐉_璁鎗:+v墾?撸鴐




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux