From 783d78de250ba4159e5c59cdf476305ccb0814ec Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Fri, 24 Apr 2015 17:31:03 +0530 Subject: rpc: Maintain separate xlator pointer in 'rpcsvc_state' The structure 'rpcsvc_state', which maintains rpc server state had no separate pointer to track the translator. It was using the mydata pointer itself. So callers were forced to send xlator pointer as mydata which is opaque (void pointer) by function prototype. 'rpcsvc_register_init' is setting svc->mydata with xlator pointer. 'rpcsvc_register_notify' is overwriting svc->mydata with mydata pointer. And rpc interprets svc->mydata as xlator pointer internally. If someone passes non xlator structure pointer to rpcsvc_register_notify as libgfchangelog currently does, it might corrupt mydata. So interpreting opaque mydata as xlator pointer is incorrect as it is caller's choice to send mydata as any type of data to 'rpcsvc_register_notify'. Maintaining two different pointers in 'rpcsvc_state' for xlator and mydata solves the issue. BUG: 1218381 Change-Id: I4c28937a30845e3f41b6fc7a09036149c816659b Signed-off-by: Kotresh HR Reviewed-on: http://review.gluster.org/10366 Reviewed-on: http://review.gluster.org/10534 Tested-by: Gluster Build System Tested-by: NetBSD Build System Reviewed-by: Aravinda VK Reviewed-by: Vijay Bellur --- xlators/protocol/server/src/server-handshake.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'xlators/protocol') diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c index 9396499cc3d..262df6a004d 100644 --- a/xlators/protocol/server/src/server-handshake.c +++ b/xlators/protocol/server/src/server-handshake.c @@ -254,7 +254,7 @@ server_getspec (rpcsvc_request_t *req) gf_getspec_req args = {0,}; gf_getspec_rsp rsp = {0,}; - this = req->svc->mydata; + this = req->svc->xl; conf = this->private; ret = xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gf_getspec_req); @@ -364,7 +364,7 @@ server_setvolume (rpcsvc_request_t *req) goto fail; } - this = req->svc->mydata; + this = req->svc->xl; config_params = dict_copy_with_ref (this->options, NULL); conf = this->private; @@ -735,7 +735,7 @@ server_set_lk_version (rpcsvc_request_t *req) server_ctx_t *serv_ctx = NULL; xlator_t *this = NULL; - this = req->svc->mydata; + this = req->svc->xl; //TODO: Decide on an appropriate errno for the error-path //below if (!this) -- cgit