Skip to content

Commit df14cbf

Browse files
committed
fix for buffer length check (rdma osc w/ odd datatypes)
The osc_rdma_get_remote_segment() has the 3rd and 4th args as * target_disp * length which it uses to determine if the rdma falls within the bounds of the window or not (actually it only checks the upper bound, but I'm okay with that). Anyway the caller previously was passing in the length argument as target_datatype->super.size * target_count which which doesn't really represent the number of bytes after target_disp for which data exists. In particular I could create a datatype as { disp -4, len 4 } and use target_disp 4 and that would be bytes 0-3 of the window where the original code would think it was bytes 4-7 and could abort at the range check. Ive changed it to use the opal_datatype_span() function. Signed-off-by: Mark Allen <[email protected]>
1 parent 02c288c commit df14cbf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ompi/mca/osc/rdma/osc_rdma_comm.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Copyright (c) 2016 Intel, Inc. All rights reserved.
66
* Copyright (c) 2017 Research Organization for Information Science
77
* and Technology (RIST). All rights reserved.
8+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
89
* $COPYRIGHT$
910
*
1011
* Additional copyrights may follow
@@ -793,7 +794,14 @@ static inline int ompi_osc_rdma_put_w_req (ompi_osc_rdma_sync_t *sync, const voi
793794
return OMPI_SUCCESS;
794795
}
795796

796-
ret = osc_rdma_get_remote_segment (module, peer, target_disp, target_datatype->super.size * target_count,
797+
ptrdiff_t len, offset;
798+
// a buffer defined by (buf, count, dt)
799+
// will have data starting at buf+offset and ending len bytes later:
800+
len = opal_datatype_span(&target_datatype->super, target_count, &offset);
801+
802+
// the below function wants arg4 to be the number of bytes after
803+
// source_disp that the data ends, which is offset+len
804+
ret = osc_rdma_get_remote_segment (module, peer, target_disp, offset+len,
797805
&target_address, &target_handle);
798806
if (OPAL_UNLIKELY(OMPI_SUCCESS != ret)) {
799807
return ret;

0 commit comments

Comments
 (0)