Re: [PATCH v3 1/5] KVM: stats: Support linear and logarithmic histogram statistics

Paolo Bonzini <[email protected]>
Newsgroups org.kernel.vger.kvm-ppc,org.kernel.vger.kvm
Message-ID <[email protected]>
On 02/08/21 18:56, Jing Zhang wrote:
> +	index = array_index_nospec(index, size);
> +	++data[index];

This would have to use

	index = min(index, size-1);
	index = array_index_nospec(index, size);

But thinking more about it there should be no way to do *two* 
consecutive accesses.  Thus, it would be possible to bring an out of 
bounds element of data[] in the cache, but it would not be possible to 
deduce its value.

This might have to be taken into account when adding more statistics, 
but for now I've simply replaced array_index_nospec with the min() above.

Paolo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.