From 644779e38de4a7bbc126ea242043f2170275a7dd Mon Sep 17 00:00:00 2001 From: Bruno Faccini Date: Tue, 23 Mar 2021 19:07:40 +0100 Subject: [PATCH] DAOS-6709 rsvc: xfer only attr size and fix tests (#4745) This is a new way to fix extra data leak problem if destination buffer is larger than real attr size. To allow for only requested or attr exact size to be sent and avoid packing by Mercury, each segment has to be sent as a single bulk transfer instead as all being part of the same bulk transfer and have Mercury do own management. This allows to conform with original behaviour, so no associated tests need to be modified anymore. Signed-off-by: Bruno Faccini --- src/rsvc/srv_common.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/rsvc/srv_common.c b/src/rsvc/srv_common.c index dcab9949a64..30faf17b1ba 100644 --- a/src/rsvc/srv_common.c +++ b/src/rsvc/srv_common.c @@ -176,6 +176,7 @@ ds_rsvc_get_attr(struct ds_rsvc *svc, struct rdb_tx *tx, rdb_path_t *path, crt_bulk_t local_bulk; daos_size_t bulk_size; daos_size_t input_size; + daos_size_t local_offset, remote_offset; d_iov_t *iovs; d_sg_list_t sgl; void *data; @@ -259,7 +260,28 @@ ds_rsvc_get_attr(struct ds_rsvc *svc, struct rdb_tx *tx, rdb_path_t *path, goto out_iovs; rc = attr_bulk_transfer(rpc, CRT_BULK_PUT, local_bulk, remote_bulk, - 0, key_length, bulk_size - key_length); + 0, key_length, count * sizeof(*sizes)); + if (rc != 0) + goto out_iovs; + + local_offset = count * sizeof(*sizes); + remote_offset = key_length + count * sizeof(*sizes); + + for (i = 1; i < sgl.sg_nr; i++) { + daos_size_t size; + + size = min(sgl.sg_iovs[i].iov_len, + sgl.sg_iovs[i].iov_buf_len); + rc = attr_bulk_transfer(rpc, CRT_BULK_PUT, local_bulk, + remote_bulk, local_offset, + remote_offset, size); + if (rc != 0) + goto out_iovs; + + local_offset += sgl.sg_iovs[i].iov_buf_len; + remote_offset += sgl.sg_iovs[i].iov_buf_len; + } + crt_bulk_free(local_bulk); if (rc != 0) goto out_iovs;