auth_x.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. #include "ceph_debug.h"
  2. #include <linux/err.h>
  3. #include <linux/module.h>
  4. #include <linux/random.h>
  5. #include "auth_x.h"
  6. #include "auth_x_protocol.h"
  7. #include "crypto.h"
  8. #include "auth.h"
  9. #include "decode.h"
  10. struct kmem_cache *ceph_x_ticketbuf_cachep;
  11. #define TEMP_TICKET_BUF_LEN 256
  12. static void ceph_x_validate_tickets(struct ceph_auth_client *ac, int *pneed);
  13. static int ceph_x_is_authenticated(struct ceph_auth_client *ac)
  14. {
  15. struct ceph_x_info *xi = ac->private;
  16. int need;
  17. ceph_x_validate_tickets(ac, &need);
  18. dout("ceph_x_is_authenticated want=%d need=%d have=%d\n",
  19. ac->want_keys, need, xi->have_keys);
  20. return (ac->want_keys & xi->have_keys) == ac->want_keys;
  21. }
  22. static int ceph_x_encrypt(struct ceph_crypto_key *secret,
  23. void *ibuf, int ilen, void *obuf, size_t olen)
  24. {
  25. struct ceph_x_encrypt_header head = {
  26. .struct_v = 1,
  27. .magic = cpu_to_le64(CEPHX_ENC_MAGIC)
  28. };
  29. size_t len = olen - sizeof(u32);
  30. int ret;
  31. ret = ceph_encrypt2(secret, obuf + sizeof(u32), &len,
  32. &head, sizeof(head), ibuf, ilen);
  33. if (ret)
  34. return ret;
  35. ceph_encode_32(&obuf, len);
  36. return len + sizeof(u32);
  37. }
  38. static int ceph_x_decrypt(struct ceph_crypto_key *secret,
  39. void **p, void *end, void *obuf, size_t olen)
  40. {
  41. struct ceph_x_encrypt_header head;
  42. size_t head_len = sizeof(head);
  43. int len, ret;
  44. len = ceph_decode_32(p);
  45. if (*p + len > end)
  46. return -EINVAL;
  47. dout("ceph_x_decrypt len %d\n", len);
  48. ret = ceph_decrypt2(secret, &head, &head_len, obuf, &olen,
  49. *p, len);
  50. if (ret)
  51. return ret;
  52. if (head.struct_v != 1 || le64_to_cpu(head.magic) != CEPHX_ENC_MAGIC)
  53. return -EPERM;
  54. *p += len;
  55. return olen;
  56. }
  57. /*
  58. * get existing (or insert new) ticket handler
  59. */
  60. struct ceph_x_ticket_handler *get_ticket_handler(struct ceph_auth_client *ac,
  61. int service)
  62. {
  63. struct ceph_x_ticket_handler *th;
  64. struct ceph_x_info *xi = ac->private;
  65. struct rb_node *parent = NULL, **p = &xi->ticket_handlers.rb_node;
  66. while (*p) {
  67. parent = *p;
  68. th = rb_entry(parent, struct ceph_x_ticket_handler, node);
  69. if (service < th->service)
  70. p = &(*p)->rb_left;
  71. else if (service > th->service)
  72. p = &(*p)->rb_right;
  73. else
  74. return th;
  75. }
  76. /* add it */
  77. th = kzalloc(sizeof(*th), GFP_NOFS);
  78. if (!th)
  79. return ERR_PTR(-ENOMEM);
  80. th->service = service;
  81. rb_link_node(&th->node, parent, p);
  82. rb_insert_color(&th->node, &xi->ticket_handlers);
  83. return th;
  84. }
  85. static void remove_ticket_handler(struct ceph_auth_client *ac,
  86. struct ceph_x_ticket_handler *th)
  87. {
  88. struct ceph_x_info *xi = ac->private;
  89. dout("remove_ticket_handler %p %d\n", th, th->service);
  90. rb_erase(&th->node, &xi->ticket_handlers);
  91. ceph_crypto_key_destroy(&th->session_key);
  92. if (th->ticket_blob)
  93. ceph_buffer_put(th->ticket_blob);
  94. kfree(th);
  95. }
  96. static int ceph_x_proc_ticket_reply(struct ceph_auth_client *ac,
  97. struct ceph_crypto_key *secret,
  98. void *buf, void *end)
  99. {
  100. struct ceph_x_info *xi = ac->private;
  101. int num;
  102. void *p = buf;
  103. int ret;
  104. char *dbuf;
  105. char *ticket_buf;
  106. u8 struct_v;
  107. dbuf = kmem_cache_alloc(ceph_x_ticketbuf_cachep, GFP_NOFS | GFP_ATOMIC);
  108. if (!dbuf)
  109. return -ENOMEM;
  110. ret = -ENOMEM;
  111. ticket_buf = kmem_cache_alloc(ceph_x_ticketbuf_cachep,
  112. GFP_NOFS | GFP_ATOMIC);
  113. if (!ticket_buf)
  114. goto out_dbuf;
  115. ceph_decode_need(&p, end, 1 + sizeof(u32), bad);
  116. struct_v = ceph_decode_8(&p);
  117. if (struct_v != 1)
  118. goto bad;
  119. num = ceph_decode_32(&p);
  120. dout("%d tickets\n", num);
  121. while (num--) {
  122. int type;
  123. u8 struct_v;
  124. struct ceph_x_ticket_handler *th;
  125. void *dp, *dend;
  126. int dlen;
  127. char is_enc;
  128. struct timespec validity;
  129. struct ceph_crypto_key old_key;
  130. void *tp, *tpend;
  131. ceph_decode_need(&p, end, sizeof(u32) + 1, bad);
  132. type = ceph_decode_32(&p);
  133. dout(" ticket type %d %s\n", type, ceph_entity_type_name(type));
  134. struct_v = ceph_decode_8(&p);
  135. if (struct_v != 1)
  136. goto bad;
  137. th = get_ticket_handler(ac, type);
  138. if (IS_ERR(th)) {
  139. ret = PTR_ERR(th);
  140. goto out;
  141. }
  142. /* blob for me */
  143. dlen = ceph_x_decrypt(secret, &p, end, dbuf,
  144. TEMP_TICKET_BUF_LEN);
  145. if (dlen <= 0) {
  146. ret = dlen;
  147. goto out;
  148. }
  149. dout(" decrypted %d bytes\n", dlen);
  150. dend = dbuf + dlen;
  151. dp = dbuf;
  152. struct_v = ceph_decode_8(&dp);
  153. if (struct_v != 1)
  154. goto bad;
  155. memcpy(&old_key, &th->session_key, sizeof(old_key));
  156. ret = ceph_crypto_key_decode(&th->session_key, &dp, dend);
  157. if (ret)
  158. goto out;
  159. ceph_decode_copy(&dp, &th->validity, sizeof(th->validity));
  160. ceph_decode_timespec(&validity, &th->validity);
  161. th->expires = get_seconds() + validity.tv_sec;
  162. th->renew_after = th->expires - (validity.tv_sec / 4);
  163. dout(" expires=%lu renew_after=%lu\n", th->expires,
  164. th->renew_after);
  165. /* ticket blob for service */
  166. ceph_decode_8_safe(&p, end, is_enc, bad);
  167. tp = ticket_buf;
  168. if (is_enc) {
  169. /* encrypted */
  170. dout(" encrypted ticket\n");
  171. dlen = ceph_x_decrypt(&old_key, &p, end, ticket_buf,
  172. TEMP_TICKET_BUF_LEN);
  173. if (dlen < 0) {
  174. ret = dlen;
  175. goto out;
  176. }
  177. dlen = ceph_decode_32(&tp);
  178. } else {
  179. /* unencrypted */
  180. ceph_decode_32_safe(&p, end, dlen, bad);
  181. ceph_decode_need(&p, end, dlen, bad);
  182. ceph_decode_copy(&p, ticket_buf, dlen);
  183. }
  184. tpend = tp + dlen;
  185. dout(" ticket blob is %d bytes\n", dlen);
  186. ceph_decode_need(&tp, tpend, 1 + sizeof(u64), bad);
  187. struct_v = ceph_decode_8(&tp);
  188. th->secret_id = ceph_decode_64(&tp);
  189. ret = ceph_decode_buffer(&th->ticket_blob, &tp, tpend);
  190. if (ret)
  191. goto out;
  192. dout(" got ticket service %d (%s) secret_id %lld len %d\n",
  193. type, ceph_entity_type_name(type), th->secret_id,
  194. (int)th->ticket_blob->vec.iov_len);
  195. xi->have_keys |= th->service;
  196. }
  197. ret = 0;
  198. out:
  199. kmem_cache_free(ceph_x_ticketbuf_cachep, ticket_buf);
  200. out_dbuf:
  201. kmem_cache_free(ceph_x_ticketbuf_cachep, dbuf);
  202. return ret;
  203. bad:
  204. ret = -EINVAL;
  205. goto out;
  206. }
  207. static int ceph_x_build_authorizer(struct ceph_auth_client *ac,
  208. struct ceph_x_ticket_handler *th,
  209. struct ceph_x_authorizer *au)
  210. {
  211. int len;
  212. struct ceph_x_authorize_a *msg_a;
  213. struct ceph_x_authorize_b msg_b;
  214. void *p, *end;
  215. int ret;
  216. int ticket_blob_len =
  217. (th->ticket_blob ? th->ticket_blob->vec.iov_len : 0);
  218. dout("build_authorizer for %s %p\n",
  219. ceph_entity_type_name(th->service), au);
  220. len = sizeof(*msg_a) + sizeof(msg_b) + sizeof(u32) +
  221. ticket_blob_len + 16;
  222. dout(" need len %d\n", len);
  223. if (au->buf && au->buf->alloc_len < len) {
  224. ceph_buffer_put(au->buf);
  225. au->buf = NULL;
  226. }
  227. if (!au->buf) {
  228. au->buf = ceph_buffer_new(len, GFP_NOFS);
  229. if (!au->buf)
  230. return -ENOMEM;
  231. }
  232. au->service = th->service;
  233. msg_a = au->buf->vec.iov_base;
  234. msg_a->struct_v = 1;
  235. msg_a->global_id = cpu_to_le64(ac->global_id);
  236. msg_a->service_id = cpu_to_le32(th->service);
  237. msg_a->ticket_blob.struct_v = 1;
  238. msg_a->ticket_blob.secret_id = cpu_to_le64(th->secret_id);
  239. msg_a->ticket_blob.blob_len = cpu_to_le32(ticket_blob_len);
  240. if (ticket_blob_len) {
  241. memcpy(msg_a->ticket_blob.blob, th->ticket_blob->vec.iov_base,
  242. th->ticket_blob->vec.iov_len);
  243. }
  244. dout(" th %p secret_id %lld %lld\n", th, th->secret_id,
  245. le64_to_cpu(msg_a->ticket_blob.secret_id));
  246. p = msg_a + 1;
  247. p += ticket_blob_len;
  248. end = au->buf->vec.iov_base + au->buf->vec.iov_len;
  249. get_random_bytes(&au->nonce, sizeof(au->nonce));
  250. msg_b.struct_v = 1;
  251. msg_b.nonce = cpu_to_le64(au->nonce);
  252. ret = ceph_x_encrypt(&th->session_key, &msg_b, sizeof(msg_b),
  253. p, end - p);
  254. if (ret < 0)
  255. goto out_buf;
  256. p += ret;
  257. au->buf->vec.iov_len = p - au->buf->vec.iov_base;
  258. dout(" built authorizer nonce %llx len %d\n", au->nonce,
  259. (int)au->buf->vec.iov_len);
  260. return 0;
  261. out_buf:
  262. ceph_buffer_put(au->buf);
  263. au->buf = NULL;
  264. return ret;
  265. }
  266. static int ceph_x_encode_ticket(struct ceph_x_ticket_handler *th,
  267. void **p, void *end)
  268. {
  269. ceph_decode_need(p, end, 1 + sizeof(u64), bad);
  270. ceph_encode_8(p, 1);
  271. ceph_encode_64(p, th->secret_id);
  272. if (th->ticket_blob) {
  273. const char *buf = th->ticket_blob->vec.iov_base;
  274. u32 len = th->ticket_blob->vec.iov_len;
  275. ceph_encode_32_safe(p, end, len, bad);
  276. ceph_encode_copy_safe(p, end, buf, len, bad);
  277. } else {
  278. ceph_encode_32_safe(p, end, 0, bad);
  279. }
  280. return 0;
  281. bad:
  282. return -ERANGE;
  283. }
  284. static void ceph_x_validate_tickets(struct ceph_auth_client *ac, int *pneed)
  285. {
  286. int want = ac->want_keys;
  287. struct ceph_x_info *xi = ac->private;
  288. int service;
  289. *pneed = ac->want_keys & ~(xi->have_keys);
  290. for (service = 1; service <= want; service <<= 1) {
  291. struct ceph_x_ticket_handler *th;
  292. if (!(ac->want_keys & service))
  293. continue;
  294. if (*pneed & service)
  295. continue;
  296. th = get_ticket_handler(ac, service);
  297. if (!th) {
  298. *pneed |= service;
  299. continue;
  300. }
  301. if (get_seconds() >= th->renew_after)
  302. *pneed |= service;
  303. if (get_seconds() >= th->expires)
  304. xi->have_keys &= ~service;
  305. }
  306. }
  307. static int ceph_x_build_request(struct ceph_auth_client *ac,
  308. void *buf, void *end)
  309. {
  310. struct ceph_x_info *xi = ac->private;
  311. int need;
  312. struct ceph_x_request_header *head = buf;
  313. int ret;
  314. struct ceph_x_ticket_handler *th =
  315. get_ticket_handler(ac, CEPH_ENTITY_TYPE_AUTH);
  316. ceph_x_validate_tickets(ac, &need);
  317. dout("build_request want %x have %x need %x\n",
  318. ac->want_keys, xi->have_keys, need);
  319. if (need & CEPH_ENTITY_TYPE_AUTH) {
  320. struct ceph_x_authenticate *auth = (void *)(head + 1);
  321. void *p = auth + 1;
  322. struct ceph_x_challenge_blob tmp;
  323. char tmp_enc[40];
  324. u64 *u;
  325. if (p > end)
  326. return -ERANGE;
  327. dout(" get_auth_session_key\n");
  328. head->op = cpu_to_le16(CEPHX_GET_AUTH_SESSION_KEY);
  329. /* encrypt and hash */
  330. get_random_bytes(&auth->client_challenge, sizeof(u64));
  331. tmp.client_challenge = auth->client_challenge;
  332. tmp.server_challenge = cpu_to_le64(xi->server_challenge);
  333. ret = ceph_x_encrypt(&xi->secret, &tmp, sizeof(tmp),
  334. tmp_enc, sizeof(tmp_enc));
  335. if (ret < 0)
  336. return ret;
  337. auth->struct_v = 1;
  338. auth->key = 0;
  339. for (u = (u64 *)tmp_enc; u + 1 <= (u64 *)(tmp_enc + ret); u++)
  340. auth->key ^= *u;
  341. dout(" server_challenge %llx client_challenge %llx key %llx\n",
  342. xi->server_challenge, le64_to_cpu(auth->client_challenge),
  343. le64_to_cpu(auth->key));
  344. /* now encode the old ticket if exists */
  345. ret = ceph_x_encode_ticket(th, &p, end);
  346. if (ret < 0)
  347. return ret;
  348. return p - buf;
  349. }
  350. if (need) {
  351. void *p = head + 1;
  352. struct ceph_x_service_ticket_request *req;
  353. if (p > end)
  354. return -ERANGE;
  355. head->op = cpu_to_le16(CEPHX_GET_PRINCIPAL_SESSION_KEY);
  356. BUG_ON(!th);
  357. ret = ceph_x_build_authorizer(ac, th, &xi->auth_authorizer);
  358. if (ret)
  359. return ret;
  360. ceph_encode_copy(&p, xi->auth_authorizer.buf->vec.iov_base,
  361. xi->auth_authorizer.buf->vec.iov_len);
  362. req = p;
  363. req->keys = cpu_to_le32(need);
  364. p += sizeof(*req);
  365. return p - buf;
  366. }
  367. return 0;
  368. }
  369. static int ceph_x_handle_reply(struct ceph_auth_client *ac, int result,
  370. void *buf, void *end)
  371. {
  372. struct ceph_x_info *xi = ac->private;
  373. struct ceph_x_reply_header *head = buf;
  374. struct ceph_x_ticket_handler *th;
  375. int len = end - buf;
  376. int op;
  377. int ret;
  378. if (result)
  379. return result; /* XXX hmm? */
  380. if (xi->starting) {
  381. /* it's a hello */
  382. struct ceph_x_server_challenge *sc = buf;
  383. if (len != sizeof(*sc))
  384. return -EINVAL;
  385. xi->server_challenge = le64_to_cpu(sc->server_challenge);
  386. dout("handle_reply got server challenge %llx\n",
  387. xi->server_challenge);
  388. xi->starting = false;
  389. xi->have_keys &= ~CEPH_ENTITY_TYPE_AUTH;
  390. return -EAGAIN;
  391. }
  392. op = le32_to_cpu(head->op);
  393. result = le32_to_cpu(head->result);
  394. dout("handle_reply op %d result %d\n", op, result);
  395. switch (op) {
  396. case CEPHX_GET_AUTH_SESSION_KEY:
  397. /* verify auth key */
  398. ret = ceph_x_proc_ticket_reply(ac, &xi->secret,
  399. buf + sizeof(*head), end);
  400. break;
  401. case CEPHX_GET_PRINCIPAL_SESSION_KEY:
  402. th = get_ticket_handler(ac, CEPH_ENTITY_TYPE_AUTH);
  403. BUG_ON(!th);
  404. ret = ceph_x_proc_ticket_reply(ac, &th->session_key,
  405. buf + sizeof(*head), end);
  406. break;
  407. default:
  408. return -EINVAL;
  409. }
  410. if (ret)
  411. return ret;
  412. if (ac->want_keys == xi->have_keys)
  413. return 0;
  414. return -EAGAIN;
  415. }
  416. static int ceph_x_create_authorizer(
  417. struct ceph_auth_client *ac, int peer_type,
  418. struct ceph_authorizer **a,
  419. void **buf, size_t *len,
  420. void **reply_buf, size_t *reply_len)
  421. {
  422. struct ceph_x_authorizer *au;
  423. struct ceph_x_ticket_handler *th;
  424. int ret;
  425. th = get_ticket_handler(ac, peer_type);
  426. if (IS_ERR(th))
  427. return PTR_ERR(th);
  428. au = kzalloc(sizeof(*au), GFP_NOFS);
  429. if (!au)
  430. return -ENOMEM;
  431. ret = ceph_x_build_authorizer(ac, th, au);
  432. if (ret) {
  433. kfree(au);
  434. return ret;
  435. }
  436. *a = (struct ceph_authorizer *)au;
  437. *buf = au->buf->vec.iov_base;
  438. *len = au->buf->vec.iov_len;
  439. *reply_buf = au->reply_buf;
  440. *reply_len = sizeof(au->reply_buf);
  441. return 0;
  442. }
  443. static int ceph_x_verify_authorizer_reply(struct ceph_auth_client *ac,
  444. struct ceph_authorizer *a, size_t len)
  445. {
  446. struct ceph_x_authorizer *au = (void *)a;
  447. struct ceph_x_ticket_handler *th;
  448. int ret = 0;
  449. struct ceph_x_authorize_reply reply;
  450. void *p = au->reply_buf;
  451. void *end = p + sizeof(au->reply_buf);
  452. th = get_ticket_handler(ac, au->service);
  453. if (!th)
  454. return -EIO; /* hrm! */
  455. ret = ceph_x_decrypt(&th->session_key, &p, end, &reply, sizeof(reply));
  456. if (ret < 0)
  457. return ret;
  458. if (ret != sizeof(reply))
  459. return -EPERM;
  460. if (au->nonce + 1 != le64_to_cpu(reply.nonce_plus_one))
  461. ret = -EPERM;
  462. else
  463. ret = 0;
  464. dout("verify_authorizer_reply nonce %llx got %llx ret %d\n",
  465. au->nonce, le64_to_cpu(reply.nonce_plus_one), ret);
  466. return ret;
  467. }
  468. static void ceph_x_destroy_authorizer(struct ceph_auth_client *ac,
  469. struct ceph_authorizer *a)
  470. {
  471. struct ceph_x_authorizer *au = (void *)a;
  472. ceph_buffer_put(au->buf);
  473. kfree(au);
  474. }
  475. static void ceph_x_reset(struct ceph_auth_client *ac)
  476. {
  477. struct ceph_x_info *xi = ac->private;
  478. dout("reset\n");
  479. xi->starting = true;
  480. xi->server_challenge = 0;
  481. }
  482. static void ceph_x_destroy(struct ceph_auth_client *ac)
  483. {
  484. struct ceph_x_info *xi = ac->private;
  485. struct rb_node *p;
  486. dout("ceph_x_destroy %p\n", ac);
  487. ceph_crypto_key_destroy(&xi->secret);
  488. while ((p = rb_first(&xi->ticket_handlers)) != NULL) {
  489. struct ceph_x_ticket_handler *th =
  490. rb_entry(p, struct ceph_x_ticket_handler, node);
  491. remove_ticket_handler(ac, th);
  492. }
  493. kmem_cache_destroy(ceph_x_ticketbuf_cachep);
  494. kfree(ac->private);
  495. ac->private = NULL;
  496. }
  497. static void ceph_x_invalidate_authorizer(struct ceph_auth_client *ac,
  498. int peer_type)
  499. {
  500. struct ceph_x_ticket_handler *th;
  501. th = get_ticket_handler(ac, peer_type);
  502. if (th && !IS_ERR(th))
  503. remove_ticket_handler(ac, th);
  504. }
  505. static const struct ceph_auth_client_ops ceph_x_ops = {
  506. .is_authenticated = ceph_x_is_authenticated,
  507. .build_request = ceph_x_build_request,
  508. .handle_reply = ceph_x_handle_reply,
  509. .create_authorizer = ceph_x_create_authorizer,
  510. .verify_authorizer_reply = ceph_x_verify_authorizer_reply,
  511. .destroy_authorizer = ceph_x_destroy_authorizer,
  512. .invalidate_authorizer = ceph_x_invalidate_authorizer,
  513. .reset = ceph_x_reset,
  514. .destroy = ceph_x_destroy,
  515. };
  516. int ceph_x_init(struct ceph_auth_client *ac)
  517. {
  518. struct ceph_x_info *xi;
  519. int ret;
  520. dout("ceph_x_init %p\n", ac);
  521. xi = kzalloc(sizeof(*xi), GFP_NOFS);
  522. if (!xi)
  523. return -ENOMEM;
  524. ret = -ENOMEM;
  525. ceph_x_ticketbuf_cachep = kmem_cache_create("ceph_x_ticketbuf",
  526. TEMP_TICKET_BUF_LEN, 8,
  527. (SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD),
  528. NULL);
  529. if (!ceph_x_ticketbuf_cachep)
  530. goto done_nomem;
  531. ret = -EINVAL;
  532. if (!ac->secret) {
  533. pr_err("no secret set (for auth_x protocol)\n");
  534. goto done_nomem;
  535. }
  536. ret = ceph_crypto_key_unarmor(&xi->secret, ac->secret);
  537. if (ret)
  538. goto done_nomem;
  539. xi->starting = true;
  540. xi->ticket_handlers = RB_ROOT;
  541. ac->protocol = CEPH_AUTH_CEPHX;
  542. ac->private = xi;
  543. ac->ops = &ceph_x_ops;
  544. return 0;
  545. done_nomem:
  546. kfree(xi);
  547. if (ceph_x_ticketbuf_cachep)
  548. kmem_cache_destroy(ceph_x_ticketbuf_cachep);
  549. return ret;
  550. }