lkml.org 
[lkml]   [2008]   [Dec]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[patch 014/104] sysvipc: fix the ipc structures initialization
    2.6.27-stable review patch.  If anyone has any objections, please let us know.

    ------------------
    From: Nadia Derbey <Nadia.Derbey@bull.net>

    commit e00b4ff7ebf098b11b11be403921c1cf41d9e321 upstream.

    A problem was found while reviewing the code after Bugzilla bug
    http://bugzilla.kernel.org/show_bug.cgi?id=11796.

    In ipc_addid(), the newly allocated ipc structure is inserted into the
    ipcs tree (i.e made visible to readers) without locking it. This is not
    correct since its initialization continues after it has been inserted in
    the tree.

    This patch moves the ipc structure lock initialization + locking before
    the actual insertion.

    Signed-off-by: Nadia Derbey <Nadia.Derbey@bull.net>
    Reported-by: Clement Calmels <cboulte@gmail.com>
    Cc: Manfred Spraul <manfred@colorfullife.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

    ---
    ipc/util.c | 14 +++++++++-----
    1 file changed, 9 insertions(+), 5 deletions(-)

    --- a/ipc/util.c
    +++ b/ipc/util.c
    @@ -266,9 +266,17 @@ int ipc_addid(struct ipc_ids* ids, struc
    if (ids->in_use >= size)
    return -ENOSPC;

    + spin_lock_init(&new->lock);
    + new->deleted = 0;
    + rcu_read_lock();
    + spin_lock(&new->lock);
    +
    err = idr_get_new(&ids->ipcs_idr, new, &id);
    - if (err)
    + if (err) {
    + spin_unlock(&new->lock);
    + rcu_read_unlock();
    return err;
    + }

    ids->in_use++;

    @@ -280,10 +288,6 @@ int ipc_addid(struct ipc_ids* ids, struc
    ids->seq = 0;

    new->id = ipc_buildid(id, new->seq);
    - spin_lock_init(&new->lock);
    - new->deleted = 0;
    - rcu_read_lock();
    - spin_lock(&new->lock);
    return id;
    }



    \
     
     \ /
      Last update: 2008-12-03 20:59    [W:4.045 / U:0.128 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site