The part_shift in RingData could be negative

Bug #924577 reported by autumn wang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Fix Released
Undecided
Samuel Merritt

Bug Description

In common/ring/build.py, during line 146-151:

            if not self._replica2part2dev:
                self._ring = RingData([], devs, 32 - self.part_power)
            else:
                self._ring = \
                RingData([array('H', p2d) for p2d in self._replica2part2dev],
                         devs, 32 - self.part_power)

If the "part_power" in class RingBuilder is larger than 32, the value of " part_shift' in class RingData will be negative.
This will cause the following code failure, which is in line 133 of file common/ring/ring.py:
part = unpack_from('>I', key)[0] >> self._part_shift

Suggest: Add value checking in RingBuilder.__init__

Changed in swift:
assignee: nobody → Bavirisetty Ramya (bavirisetty-ramya)
Revision history for this message
Pete Zaitcev (zaitcev) wrote :

I am unable to confirm it properly because my swif-ring-builder runs out of RAM when trying to rebalance a ring with 33 power :-) Still, obviously it's a problem.

Changed in swift:
status: New → Confirmed
Revision history for this message
Bavirisetty Ramya (bavirisetty-ramya) wrote :

Hi
I checked up the part_power value in the __init__ method of the RingBuilder class and raised a value error exception if the part_power is greater than 32 as below:
def __init__(self, part_power, replicas, min_part_hours):
        self.part_power = part_power
        self.replicas = replicas
        self.min_part_hours = min_part_hours
        self.parts = 2 ** self.part_power
        self.devs = []
        self.devs_changed = False
        self.version = 0
        if part_power > 32:
            raise ValueError("partpower should be less than 32")

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to swift (master)

Fix proposed to branch: master
Review: https://review.openstack.org/8471

Changed in swift:
status: Confirmed → In Progress
Changed in swift:
assignee: Bavirisetty Ramya (bavirisetty-ramya) → nobody
Changed in swift:
assignee: nobody → Samuel Merritt (torgomatic)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/24613

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (master)

Reviewed: https://review.openstack.org/24613
Committed: http://github.com/openstack/swift/commit/d42a78a3aa138ca14e1b06555ae649971799e618
Submitter: Jenkins
Branch: master

commit d42a78a3aa138ca14e1b06555ae649971799e618
Author: Samuel Merritt <email address hidden>
Date: Sun Mar 17 15:07:20 2013 -0700

    Basic ring builder validation.

    This prevents people from creating bogus ring builder files.

    Example: "swift-ring-builder object.builder create 33 0.9 -4".

    Fixes bug 924577.

    Change-Id: I7bfc04f7fa5f55f70a4eaae96c414f6b2872e283

Changed in swift:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in swift:
milestone: none → 1.8.0-rc1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in swift:
milestone: 1.8.0-rc1 → 1.8.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.