Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect checking of client RKEY #10522

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions prov/cxi/src/cxip_mr.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,14 @@ static void cxip_mr_domain_remove(struct cxip_mr *mr)
ofi_spin_unlock(&mr->domain->mr_domain.lock);
}

static bool cxip_is_valid_mr_key(uint64_t key)
{
if (key & ~CXIP_MR_KEY_MASK)
return false;

return true;
}

/*
* cxip_mr_domain_insert() - Validate uniqueness and insert
* client key in the domain hash table.
Expand All @@ -777,7 +785,7 @@ static int cxip_mr_domain_insert(struct cxip_mr *mr)

mr->key = mr->attr.requested_key;

if (!cxip_generic_is_valid_mr_key(mr->key))
if (!cxip_is_valid_mr_key(mr->key))
return -FI_EKEYREJECTED;

bucket = fasthash64(&mr->key, sizeof(mr->key), 0) %
Expand Down Expand Up @@ -851,14 +859,6 @@ static int cxip_prov_cache_init_mr_key(struct cxip_mr *mr,
return FI_SUCCESS;
}

static bool cxip_is_valid_mr_key(uint64_t key)
{
if (key & ~CXIP_MR_KEY_MASK)
return false;

return true;
}

static bool cxip_is_valid_prov_mr_key(uint64_t key)
{
struct cxip_mr_key cxip_key = {
Expand Down
19 changes: 19 additions & 0 deletions prov/cxi/test/mr.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,25 @@ Test(mr, invalid_fi_directed_recv_flag)
cr_assert_eq(ret, -FI_EINVAL, "fi_mr_regattr failed: %d", ret);
}

Test(mr, invalid_client_rkey)
{
int ret;
struct fi_mr_attr attr = {};
struct iovec iov = {};
struct fid_mr *mr;

iov.iov_len = sizeof(ret);
iov.iov_base = (void *)&ret;

attr.mr_iov = &iov;
attr.iov_count = 1;
attr.access = FI_REMOTE_READ | FI_REMOTE_WRITE;
attr.requested_key = ~1;

ret = fi_mr_regattr(cxit_domain, &attr, 0, &mr);
cr_assert_eq(ret, -FI_EKEYREJECTED, "fi_mr_regattr failed: %d", ret);
}

Test(mr, std_mrs, .timeout = 600, .disabled = true)
{
int std_mr_cnt = 16*1024;
Expand Down