lkml.org 
[lkml]   [2007]   [Jul]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH] [DLM] fix a couple of races
    Date
    From: Satyam Sharma <ssatyam@cse.iitk.ac.in>

    Fix two races in fs/dlm/config.c:

    (1) Grab the configfs subsystem semaphore before calling
    config_group_find_obj() in get_space(). This solves a potential race
    between get_space() and concurrent mkdir(2) or rmdir(2).

    (2) Grab a reference on the found config_item _while_ holding the configfs
    subsystem semaphore in get_comm(), and not after it. This solves a
    potential race between get_comm() and concurrent rmdir(2).

    Signed-off-by: Satyam Sharma <ssatyam@cse.iitk.ac.in>
    Signed-off-by: David Teigland <teigland@redhat.com>
    Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>

    diff --git a/fs/dlm/config.c b/fs/dlm/config.c
    index 822abdc..5a3d390 100644
    --- a/fs/dlm/config.c
    +++ b/fs/dlm/config.c
    @@ -748,9 +748,16 @@ static ssize_t node_weight_write(struct node *nd, const char *buf, size_t len)

    static struct space *get_space(char *name)
    {
    + struct config_item *i;
    +
    if (!space_list)
    return NULL;
    - return to_space(config_group_find_obj(space_list, name));
    +
    + down(&space_list->cg_subsys->su_sem);
    + i = config_group_find_obj(space_list, name);
    + up(&space_list->cg_subsys->su_sem);
    +
    + return to_space(i);
    }

    static void put_space(struct space *sp)
    @@ -776,20 +783,20 @@ static struct comm *get_comm(int nodeid, struct sockaddr_storage *addr)
    if (cm->nodeid != nodeid)
    continue;
    found = 1;
    + config_item_get(i);
    break;
    } else {
    if (!cm->addr_count ||
    memcmp(cm->addr[0], addr, sizeof(*addr)))
    continue;
    found = 1;
    + config_item_get(i);
    break;
    }
    }
    up(&clusters_root.subsys.su_sem);

    - if (found)
    - config_item_get(i);
    - else
    + if (!found)
    cm = NULL;
    return cm;
    }
    --
    1.5.1.2
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2007-07-09 18:29    [W:0.025 / U:0.516 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site