Subject: Re: [PATCH]snmp6 64-bit counter support in proc.c

From: "David S. Miller" <[email-masked]>
Date: Wed, 28 Jan 2004 11:09:45 -0800

On Thu, 22 Jan 2004 18:45:18 -0800
Krishna Kumar <[email-masked]> wrote:

>             / * Overflow, sync and re-read, the next read is guaranteed to
> be greater
>              * than res1.
>              */
>             synchronize_kernel();
>             res2 = *((__u64 *) (((void *) per_cpu_ptr(mib[0], i)) + sizeof
> (__u64) * nr)));

I don't understand how your scheme can work.

We're trying to detect if the upper 32-bit half of the 64-bit value
belongs with the lower-half.  We can overflow the lower-half TWICE
in the res1=...res2=... sequence you do, and this res2 reread in the if
branch can overflow itself again, combining a lower and upper half which
do not belong to each other.

This is not so trivial to fix, see? :)