netdev
[Top] [All Lists]

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

To: Krishna Kumar <kumarkr@xxxxxxxxxx>
Subject: Re: [PATCH]snmp6 64-bit counter support in proc.c
From: "David S. Miller" <davem@xxxxxxxxxx>
Date: Wed, 28 Jan 2004 11:09:45 -0800
Cc: kuznet@xxxxxxxxxxxxx, mashirle@xxxxxxxxxx, netdev@xxxxxxxxxxx, xma@xxxxxxxxxx
In-reply-to: <OF27A95A54.FAB6CE99-ON88256E24.000E2136@us.ibm.com>
References: <OF27A95A54.FAB6CE99-ON88256E24.000E2136@us.ibm.com>
Sender: netdev-bounce@xxxxxxxxxxx
On Thu, 22 Jan 2004 18:45:18 -0800
Krishna Kumar <kumarkr@xxxxxxxxxx> 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? :)

<Prev in Thread] Current Thread [Next in Thread>