integer overflow at 2^32 in quota calculations

Ken Murchison ken at oceana.com
Sat Jul 9 11:16:36 EDT 2005


James Ralston wrote:

> On 2005-07-05 at 23:00+02 Sebastian Hagedorn <Hagedorn at uni-koeln.de> wrote:
> 
> 
>>-- Paul Raines <raines at nmr.mgh.harvard.edu> is rumored to have mumbled on 5. Juli 2005 16:32:52 -0400 regarding Re: quotas not working a x86_64?:
>>
>>
>>>On Tue, 5 Jul 2005, Ken Murchison wrote:
>>>
>>>
>>>>Its possible.  I'm fairly certain that the code has been tested
>>>>successfully on 64-bit Solaris.  It seems odd that the quota
>>>>file looks OK (which means that the code successfully handled
>>>>writing the limit and usage), but fails a quota check.
>>>
>>>Actually I was setting the quota to '2000000000' which I thought
>>>was 2GB, but I guess now was 2TB.  THe system seemed to take it.
>>>Is there some maximum for a quota in the system like 2GB no matter
>>>what the setting is?
>>
>>We had this discussion a little while ago.  In the current code the
>>quota is set in KBs, but calculated in bytes.  It's a 32 bit
>>variable, so the limit is 2 GB ...
> 
> 
> Actually, it's an unsigned 32-bit value, so the limit is 4GB:
> 
>     https://bugzilla.andrew.cmu.edu/show_bug.cgi?id=2690
> 
> (Yes, we really do have users who are using more than 4GB of space.)

The limit is still 32-bit signed.  It needs to remain unsigned because 
-1 is used to disable the quota.  But because the limit is set in KB, 
the limit is actually 2TB.  All the patch does is use 64-bit for the 
quota usage so we go beyond 4GB and track up to the limit without 
overflowing.


>>this will be different in 2.3
> 
> 
> Yes, Ken fixed it on 2004-08-09 in the cyrus-imapd-2_3 branch.
> 
> Ken, off the top of your head, can you think of any gotchas in
> backporting your quota calculation fixes to 2.2?  (I don't want to
> wait until 2.3 for the fix, as this bug is currently biting us.)

I don't see any problem, as the space for the extra 4-bytes is already 
carved out in cyrus.index.  You can probably use 'cvsps' to create a 
patchset.  If you don't have it, I can make one for you.

-- 
Kenneth Murchison     Oceana Matrix Ltd.
Software Engineer     21 Princeton Place
716-662-8973 x26      Orchard Park, NY 14127
--PGP Public Key--    http://www.oceana.com/~ken/ksm.pgp
---
Cyrus Home Page: http://asg.web.cmu.edu/cyrus
Cyrus Wiki/FAQ: http://cyruswiki.andrew.cmu.edu
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html




More information about the Info-cyrus mailing list