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/features/changelog/src/changelog-rpc-common.c | 4 ++-- xlators/features/changelog/src/changelog-rpc.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'xlators/features/changelog/src') diff --git a/xlators/features/changelog/src/changelog-rpc-common.c b/xlators/features/changelog/src/changelog-rpc-common.c index 76db6696ae8..de3a730534e 100644 --- a/xlators/features/changelog/src/changelog-rpc-common.c +++ b/xlators/features/changelog/src/changelog-rpc-common.c @@ -249,8 +249,8 @@ changelog_rpc_server_destroy (xlator_t *this, rpcsvc_t *rpc, char *sockfile, rpcsvc_notify_t fn, struct rpcsvc_program **progs) { rpcsvc_listener_t *listener = NULL; - rpcsvc_listener_t *next = NULL; - struct rpcsvc_program *prog = NULL; + rpcsvc_listener_t *next = NULL; + struct rpcsvc_program *prog = NULL; while (*progs) { prog = *progs; diff --git a/xlators/features/changelog/src/changelog-rpc.c b/xlators/features/changelog/src/changelog-rpc.c index 04326456d31..ffbc61e40f9 100644 --- a/xlators/features/changelog/src/changelog-rpc.c +++ b/xlators/features/changelog/src/changelog-rpc.c @@ -253,7 +253,7 @@ changelog_handle_probe (rpcsvc_request_t *req) /* ->xl hidden in rpcsvc */ svc = rpcsvc_request_service (req); - this = svc->mydata; + this = svc->xl; priv = this->private; c_clnt = &priv->connections; -- cgit