Skip to content

Commit e3e4d73

Browse files
author
Ralph Castain
committed
Need to be a little more careful when checking the range on a publish/lookup operation. If the range was constrained at publish, then we need to check that the lookup fits within that constraint. Otherwise, we should provide the data. More detailed constraint checking will be provided later.
1 parent 0d85d68 commit e3e4d73

File tree

2 files changed

+40
-13
lines changed

2 files changed

+40
-13
lines changed

orte/orted/pmix/pmix_server_pub.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ int pmix_server_publish_fn(opal_process_name_t *proc,
121121
pset = false;
122122
OPAL_LIST_FOREACH(iptr, info, opal_value_t) {
123123
if (0 == strcmp(iptr->key, OPAL_PMIX_RANGE)) {
124-
range = (opal_pmix_data_range_t)iptr->data.integer;
124+
range = (opal_pmix_data_range_t)iptr->data.uint;
125125
if (pset) {
126126
break;
127127
}
@@ -136,7 +136,7 @@ int pmix_server_publish_fn(opal_process_name_t *proc,
136136
}
137137

138138
/* pack the range */
139-
if (OPAL_SUCCESS != (rc = opal_dss.pack(&req->msg, &range, 1, OPAL_INT))) {
139+
if (OPAL_SUCCESS != (rc = opal_dss.pack(&req->msg, &range, 1, OPAL_PMIX_DATA_RANGE))) {
140140
ORTE_ERROR_LOG(rc);
141141
OBJ_RELEASE(req);
142142
return rc;
@@ -211,10 +211,17 @@ int pmix_server_lookup_fn(opal_process_name_t *proc, char **keys,
211211
return rc;
212212
}
213213

214+
/* pack the requesting process jobid */
215+
if (OPAL_SUCCESS != (rc = opal_dss.pack(&req->msg, &proc->jobid, 1, ORTE_JOBID))) {
216+
ORTE_ERROR_LOG(rc);
217+
OBJ_RELEASE(req);
218+
return rc;
219+
}
220+
214221
/* no help for it - need to search for range */
215222
OPAL_LIST_FOREACH(iptr, info, opal_value_t) {
216223
if (0 == strcmp(iptr->key, OPAL_PMIX_RANGE)) {
217-
range = (opal_pmix_data_range_t)iptr->data.integer;
224+
range = (opal_pmix_data_range_t)iptr->data.uint;
218225
break;
219226
}
220227
}

orte/runtime/orte_data_server.c

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ typedef struct {
6969
static void construct(orte_data_object_t *ptr)
7070
{
7171
ptr->index = -1;
72+
ptr->uid = UINT32_MAX;
73+
ptr->range = OPAL_PMIX_RANGE_UNDEF;
74+
ptr->persistence = OPAL_PMIX_PERSIST_SESSION;
7275
OBJ_CONSTRUCT(&ptr->values, opal_list_t);
7376
}
7477

@@ -172,9 +175,10 @@ void orte_data_server(int status, orte_process_name_t* sender,
172175
char **keys = NULL, *str;
173176
bool ret_packed = false, wait = false, data_added;
174177
int room_number;
175-
uint32_t uid;
178+
uint32_t uid = UINT32_MAX;
176179
opal_pmix_data_range_t range;
177180
orte_data_req_t *req, *rqnext;
181+
orte_jobid_t jobid;
178182

179183
OPAL_OUTPUT_VERBOSE((1, orte_debug_output,
180184
"%s data server got message from %s",
@@ -206,7 +210,7 @@ void orte_data_server(int status, orte_process_name_t* sender,
206210
switch(command) {
207211
case ORTE_PMIX_PUBLISH_CMD:
208212
data = OBJ_NEW(orte_data_object_t);
209-
/* unpack the requestor */
213+
/* unpack the publisher */
210214
count = 1;
211215
if (ORTE_SUCCESS != (rc = opal_dss.unpack(buffer, &data->owner, &count, OPAL_NAME))) {
212216
ORTE_ERROR_LOG(rc);
@@ -221,7 +225,7 @@ void orte_data_server(int status, orte_process_name_t* sender,
221225

222226
/* unpack the range */
223227
count = 1;
224-
if (ORTE_SUCCESS != (rc = opal_dss.unpack(buffer, &data->range, &count, OPAL_INT))) {
228+
if (ORTE_SUCCESS != (rc = opal_dss.unpack(buffer, &data->range, &count, OPAL_PMIX_DATA_RANGE))) {
225229
ORTE_ERROR_LOG(rc);
226230
OBJ_RELEASE(data);
227231
goto SEND_ERROR;
@@ -261,8 +265,13 @@ void orte_data_server(int status, orte_process_name_t* sender,
261265
if (req->uid != data->uid) {
262266
continue;
263267
}
264-
if (req->range != data->range) {
265-
continue;
268+
/* if the published range is constrained to namespace, then only
269+
* consider this data if the publisher is
270+
* in the same namespace as the requestor */
271+
if (OPAL_PMIX_RANGE_NAMESPACE == data->range) {
272+
if (jobid != data->owner.jobid) {
273+
continue;
274+
}
266275
}
267276
for (i=0; NULL != req->keys[i]; i++) {
268277
/* cycle thru the data keys for matches */
@@ -344,9 +353,16 @@ void orte_data_server(int status, orte_process_name_t* sender,
344353
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
345354
ORTE_NAME_PRINT(sender)));
346355

356+
/* unpack the requestor's jobid */
357+
count = 1;
358+
if (ORTE_SUCCESS != (rc = opal_dss.unpack(buffer, &jobid, &count, ORTE_JOBID))) {
359+
ORTE_ERROR_LOG(rc);
360+
goto SEND_ERROR;
361+
}
362+
347363
/* unpack the range - this sets some constraints on the range of data to be considered */
348364
count = 1;
349-
if (ORTE_SUCCESS != (rc = opal_dss.unpack(buffer, &range, &count, OPAL_INT))) {
365+
if (ORTE_SUCCESS != (rc = opal_dss.unpack(buffer, &range, &count, OPAL_PMIX_DATA_RANGE))) {
350366
ORTE_ERROR_LOG(rc);
351367
goto SEND_ERROR;
352368
}
@@ -409,13 +425,17 @@ void orte_data_server(int status, orte_process_name_t* sender,
409425
if (NULL == data) {
410426
continue;
411427
}
412-
/* can only access data posted by the same user id */
428+
/* for security reasons, can only access data posted by the same user id */
413429
if (uid != data->uid) {
414430
continue;
415431
}
416-
/* if the range doesn't match, then we cannot consider it */
417-
if (range != data->range) {
418-
continue;
432+
/* if the published range is constrained to namespace, then only
433+
* consider this data if the publisher is
434+
* in the same namespace as the requestor */
435+
if (OPAL_PMIX_RANGE_NAMESPACE == data->range) {
436+
if (jobid != data->owner.jobid) {
437+
continue;
438+
}
419439
}
420440
/* see if we have this key */
421441
OPAL_LIST_FOREACH(iptr, &data->values, opal_value_t) {

0 commit comments

Comments
 (0)