aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-05-16 16:16:39 -0400
committerAlex Elder <elder@dreamhost.com>2012-05-17 09:18:13 -0400
commita255651d4cad89f1a606edd36135af892ada4f20 (patch)
tree6d2c694b336f948272349e5de24be70460a94826 /net/ceph
parent74f1869f76d043bad12ec03b4d5f04a8c3d1f157 (diff)
ceph: ensure auth ops are defined before use
In the create_authorizer method for both the mds and osd clients, the auth_client->ops pointer is blindly dereferenced. There is no obvious guarantee that this pointer has been assigned. And furthermore, even if the ops pointer is non-null there is definitely no guarantee that the create_authorizer or destroy_authorizer methods are defined. Add checks in both routines to make sure they are defined (non-null) before use. Add similar checks in a few other spots in these files while we're at it. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'net/ceph')
-rw-r--r--net/ceph/osd_client.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 2da4b9e97dc1..f640bdf027e7 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -664,10 +664,10 @@ static void put_osd(struct ceph_osd *osd)
664{ 664{
665 dout("put_osd %p %d -> %d\n", osd, atomic_read(&osd->o_ref), 665 dout("put_osd %p %d -> %d\n", osd, atomic_read(&osd->o_ref),
666 atomic_read(&osd->o_ref) - 1); 666 atomic_read(&osd->o_ref) - 1);
667 if (atomic_dec_and_test(&osd->o_ref)) { 667 if (atomic_dec_and_test(&osd->o_ref) && osd->o_auth.authorizer) {
668 struct ceph_auth_client *ac = osd->o_osdc->client->monc.auth; 668 struct ceph_auth_client *ac = osd->o_osdc->client->monc.auth;
669 669
670 if (osd->o_auth.authorizer) 670 if (ac->ops && ac->ops->destroy_authorizer)
671 ac->ops->destroy_authorizer(ac, osd->o_auth.authorizer); 671 ac->ops->destroy_authorizer(ac, osd->o_auth.authorizer);
672 kfree(osd); 672 kfree(osd);
673 } 673 }
@@ -2119,10 +2119,11 @@ static int get_authorizer(struct ceph_connection *con,
2119 int ret = 0; 2119 int ret = 0;
2120 2120
2121 if (force_new && auth->authorizer) { 2121 if (force_new && auth->authorizer) {
2122 ac->ops->destroy_authorizer(ac, auth->authorizer); 2122 if (ac->ops && ac->ops->destroy_authorizer)
2123 ac->ops->destroy_authorizer(ac, auth->authorizer);
2123 auth->authorizer = NULL; 2124 auth->authorizer = NULL;
2124 } 2125 }
2125 if (auth->authorizer == NULL) { 2126 if (!auth->authorizer && ac->ops && ac->ops->create_authorizer) {
2126 ret = ac->ops->create_authorizer(ac, CEPH_ENTITY_TYPE_OSD, auth); 2127 ret = ac->ops->create_authorizer(ac, CEPH_ENTITY_TYPE_OSD, auth);
2127 if (ret) 2128 if (ret)
2128 return ret; 2129 return ret;
@@ -2144,6 +2145,10 @@ static int verify_authorizer_reply(struct ceph_connection *con, int len)
2144 struct ceph_osd_client *osdc = o->o_osdc; 2145 struct ceph_osd_client *osdc = o->o_osdc;
2145 struct ceph_auth_client *ac = osdc->client->monc.auth; 2146 struct ceph_auth_client *ac = osdc->client->monc.auth;
2146 2147
2148 /*
2149 * XXX If ac->ops or ac->ops->verify_authorizer_reply is null,
2150 * XXX which do we do: succeed or fail?
2151 */
2147 return ac->ops->verify_authorizer_reply(ac, o->o_auth.authorizer, len); 2152 return ac->ops->verify_authorizer_reply(ac, o->o_auth.authorizer, len);
2148} 2153}
2149 2154
@@ -2153,7 +2158,7 @@ static int invalidate_authorizer(struct ceph_connection *con)
2153 struct ceph_osd_client *osdc = o->o_osdc; 2158 struct ceph_osd_client *osdc = o->o_osdc;
2154 struct ceph_auth_client *ac = osdc->client->monc.auth; 2159 struct ceph_auth_client *ac = osdc->client->monc.auth;
2155 2160
2156 if (ac->ops->invalidate_authorizer) 2161 if (ac->ops && ac->ops->invalidate_authorizer)
2157 ac->ops->invalidate_authorizer(ac, CEPH_ENTITY_TYPE_OSD); 2162 ac->ops->invalidate_authorizer(ac, CEPH_ENTITY_TYPE_OSD);
2158 2163
2159 return ceph_monc_validate_auth(&osdc->client->monc); 2164 return ceph_monc_validate_auth(&osdc->client->monc);