Commit 17b38fb8 authored by Doron Tsur's avatar Doron Tsur Committed by Doug Ledford

IB/core: Fix memory corruption in ib_cache_gid_set_default_gid

When ib_cache_gid_set_default_gid is called from several threads,
updating the table could make find_gid fail, therefore a negative
index will be retruned and an invalid table entry will be used.
Locking find_gid as well fixes this problem.

Fixes: 03db3a2d ('IB/core: Add RoCE GID table management')
Signed-off-by: default avatarDoron Tsur <doront@mellanox.com>
Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 0b5c9279
...@@ -508,12 +508,12 @@ void ib_cache_gid_set_default_gid(struct ib_device *ib_dev, u8 port, ...@@ -508,12 +508,12 @@ void ib_cache_gid_set_default_gid(struct ib_device *ib_dev, u8 port,
memset(&gid_attr, 0, sizeof(gid_attr)); memset(&gid_attr, 0, sizeof(gid_attr));
gid_attr.ndev = ndev; gid_attr.ndev = ndev;
mutex_lock(&table->lock);
ix = find_gid(table, NULL, NULL, true, GID_ATTR_FIND_MASK_DEFAULT); ix = find_gid(table, NULL, NULL, true, GID_ATTR_FIND_MASK_DEFAULT);
/* Coudn't find default GID location */ /* Coudn't find default GID location */
WARN_ON(ix < 0); WARN_ON(ix < 0);
mutex_lock(&table->lock);
if (!__ib_cache_gid_get(ib_dev, port, ix, if (!__ib_cache_gid_get(ib_dev, port, ix,
&current_gid, &current_gid_attr) && &current_gid, &current_gid_attr) &&
mode == IB_CACHE_GID_DEFAULT_MODE_SET && mode == IB_CACHE_GID_DEFAULT_MODE_SET &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment