2 * Modifications for Lustre
4 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
6 * Copyright (c) 2011, 2013, Intel Corporation.
8 * Author: Eric Mei <ericm@clusterfs.com>
12 * linux/net/sunrpc/auth_gss.c
14 * RPCSEC_GSS client authentication.
16 * Copyright (c) 2000 The Regents of the University of Michigan.
17 * All rights reserved.
19 * Dug Song <dugsong@monkey.org>
20 * Andy Adamson <andros@umich.edu>
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions
26 * 1. Redistributions of source code must retain the above copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. Neither the name of the University nor the names of its
32 * contributors may be used to endorse or promote products derived
33 * from this software without specific prior written permission.
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
37 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
39 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
40 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
41 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
42 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
43 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
44 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
45 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49 #define DEBUG_SUBSYSTEM S_SEC
51 #include <linux/init.h>
52 #include <linux/module.h>
53 #include <linux/slab.h>
54 #include <linux/dcache.h>
56 #include <linux/mutex.h>
57 #include <asm/atomic.h>
59 #include <liblustre.h>
63 #include <obd_class.h>
64 #include <obd_support.h>
65 #include <obd_cksum.h>
66 #include <lustre/lustre_idl.h>
67 #include <lustre_net.h>
68 #include <lustre_import.h>
69 #include <lustre_sec.h>
72 #include "gss_internal.h"
75 #include <linux/crypto.h>
76 #include <linux/crc32.h>
79 * early reply have fixed size, respectively in privacy and integrity mode.
80 * so we calculate them only once.
82 static int gss_at_reply_off_integ;
83 static int gss_at_reply_off_priv;
86 static inline int msg_last_segidx(struct lustre_msg *msg)
88 LASSERT(msg->lm_bufcount > 0);
89 return msg->lm_bufcount - 1;
91 static inline int msg_last_seglen(struct lustre_msg *msg)
93 return msg->lm_buflens[msg_last_segidx(msg)];
96 /********************************************
98 ********************************************/
101 void gss_header_swabber(struct gss_header *ghdr)
103 __swab32s(&ghdr->gh_flags);
104 __swab32s(&ghdr->gh_proc);
105 __swab32s(&ghdr->gh_seq);
106 __swab32s(&ghdr->gh_svc);
107 __swab32s(&ghdr->gh_pad1);
108 __swab32s(&ghdr->gh_handle.len);
111 struct gss_header *gss_swab_header(struct lustre_msg *msg, int segment,
114 struct gss_header *ghdr;
116 ghdr = lustre_msg_buf(msg, segment, sizeof(*ghdr));
121 gss_header_swabber(ghdr);
123 if (sizeof(*ghdr) + ghdr->gh_handle.len > msg->lm_buflens[segment]) {
124 CERROR("gss header has length %d, now %u received\n",
125 (int) sizeof(*ghdr) + ghdr->gh_handle.len,
126 msg->lm_buflens[segment]);
135 void gss_netobj_swabber(netobj_t *obj)
137 __swab32s(&obj->len);
140 netobj_t *gss_swab_netobj(struct lustre_msg *msg, int segment)
144 obj = lustre_swab_buf(msg, segment, sizeof(*obj), gss_netobj_swabber);
145 if (obj && sizeof(*obj) + obj->len > msg->lm_buflens[segment]) {
146 CERROR("netobj require length %u but only %u received\n",
147 (unsigned int) sizeof(*obj) + obj->len,
148 msg->lm_buflens[segment]);
157 * payload should be obtained from mechanism. but currently since we
158 * only support kerberos, we could simply use fixed value.
161 * - krb5 checksum: 20
163 * for privacy mode, payload also include the cipher text which has the same
164 * size as plain text, plus possible confounder, padding both at maximum cipher
167 #define GSS_KRB5_INTEG_MAX_PAYLOAD (40)
170 int gss_mech_payload(struct gss_ctx *mechctx, int msgsize, int privacy)
173 return GSS_KRB5_INTEG_MAX_PAYLOAD + 16 + 16 + 16 + msgsize;
175 return GSS_KRB5_INTEG_MAX_PAYLOAD;
179 * return signature size, otherwise < 0 to indicate error
181 static int gss_sign_msg(struct lustre_msg *msg,
182 struct gss_ctx *mechctx,
183 enum lustre_sec_part sp,
184 __u32 flags, __u32 proc, __u32 seq, __u32 svc,
187 struct gss_header *ghdr;
188 rawobj_t text[4], mic;
189 int textcnt, max_textcnt, mic_idx;
192 LASSERT(msg->lm_bufcount >= 2);
195 LASSERT(msg->lm_buflens[0] >=
196 sizeof(*ghdr) + (handle ? handle->len : 0));
197 ghdr = lustre_msg_buf(msg, 0, 0);
199 ghdr->gh_version = PTLRPC_GSS_VERSION;
200 ghdr->gh_sp = (__u8) sp;
201 ghdr->gh_flags = flags;
202 ghdr->gh_proc = proc;
206 /* fill in a fake one */
207 ghdr->gh_handle.len = 0;
209 ghdr->gh_handle.len = handle->len;
210 memcpy(ghdr->gh_handle.data, handle->data, handle->len);
213 /* no actual signature for null mode */
214 if (svc == SPTLRPC_SVC_NULL)
215 return lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens);
218 mic_idx = msg_last_segidx(msg);
219 max_textcnt = (svc == SPTLRPC_SVC_AUTH) ? 1 : mic_idx;
221 for (textcnt = 0; textcnt < max_textcnt; textcnt++) {
222 text[textcnt].len = msg->lm_buflens[textcnt];
223 text[textcnt].data = lustre_msg_buf(msg, textcnt, 0);
226 mic.len = msg->lm_buflens[mic_idx];
227 mic.data = lustre_msg_buf(msg, mic_idx, 0);
229 major = lgss_get_mic(mechctx, textcnt, text, 0, NULL, &mic);
230 if (major != GSS_S_COMPLETE) {
231 CERROR("fail to generate MIC: %08x\n", major);
234 LASSERT(mic.len <= msg->lm_buflens[mic_idx]);
236 return lustre_shrink_msg(msg, mic_idx, mic.len, 0);
243 __u32 gss_verify_msg(struct lustre_msg *msg,
244 struct gss_ctx *mechctx,
247 rawobj_t text[4], mic;
248 int textcnt, max_textcnt;
252 LASSERT(msg->lm_bufcount >= 2);
254 if (svc == SPTLRPC_SVC_NULL)
255 return GSS_S_COMPLETE;
257 mic_idx = msg_last_segidx(msg);
258 max_textcnt = (svc == SPTLRPC_SVC_AUTH) ? 1 : mic_idx;
260 for (textcnt = 0; textcnt < max_textcnt; textcnt++) {
261 text[textcnt].len = msg->lm_buflens[textcnt];
262 text[textcnt].data = lustre_msg_buf(msg, textcnt, 0);
265 mic.len = msg->lm_buflens[mic_idx];
266 mic.data = lustre_msg_buf(msg, mic_idx, 0);
268 major = lgss_verify_mic(mechctx, textcnt, text, 0, NULL, &mic);
269 if (major != GSS_S_COMPLETE)
270 CERROR("mic verify error: %08x\n", major);
276 * return gss error code
279 __u32 gss_unseal_msg(struct gss_ctx *mechctx,
280 struct lustre_msg *msgbuf,
281 int *msg_len, int msgbuf_len)
283 rawobj_t clear_obj, hdrobj, token;
289 if (msgbuf->lm_bufcount != 2) {
290 CERROR("invalid bufcount %d\n", msgbuf->lm_bufcount);
291 RETURN(GSS_S_FAILURE);
294 /* allocate a temporary clear text buffer, same sized as token,
295 * we assume the final clear text size <= token size */
296 clear_buflen = lustre_msg_buflen(msgbuf, 1);
297 OBD_ALLOC_LARGE(clear_buf, clear_buflen);
299 RETURN(GSS_S_FAILURE);
302 hdrobj.len = lustre_msg_buflen(msgbuf, 0);
303 hdrobj.data = lustre_msg_buf(msgbuf, 0, 0);
304 token.len = lustre_msg_buflen(msgbuf, 1);
305 token.data = lustre_msg_buf(msgbuf, 1, 0);
306 clear_obj.len = clear_buflen;
307 clear_obj.data = clear_buf;
309 major = lgss_unwrap(mechctx, &hdrobj, &token, &clear_obj);
310 if (major != GSS_S_COMPLETE) {
311 CERROR("unwrap message error: %08x\n", major);
312 GOTO(out_free, major = GSS_S_FAILURE);
314 LASSERT(clear_obj.len <= clear_buflen);
315 LASSERT(clear_obj.len <= msgbuf_len);
317 /* now the decrypted message */
318 memcpy(msgbuf, clear_obj.data, clear_obj.len);
319 *msg_len = clear_obj.len;
321 major = GSS_S_COMPLETE;
323 OBD_FREE_LARGE(clear_buf, clear_buflen);
327 /********************************************
328 * gss client context manipulation helpers *
329 ********************************************/
331 int cli_ctx_expire(struct ptlrpc_cli_ctx *ctx)
333 LASSERT(cfs_atomic_read(&ctx->cc_refcount));
335 if (!test_and_set_bit(PTLRPC_CTX_DEAD_BIT, &ctx->cc_flags)) {
336 if (!ctx->cc_early_expire)
337 clear_bit(PTLRPC_CTX_UPTODATE_BIT, &ctx->cc_flags);
339 CWARN("ctx %p(%u->%s) get expired: %lu(%+lds)\n",
340 ctx, ctx->cc_vcred.vc_uid, sec2target_str(ctx->cc_sec),
342 ctx->cc_expire == 0 ? 0 :
343 cfs_time_sub(ctx->cc_expire, cfs_time_current_sec()));
345 sptlrpc_cli_ctx_wakeup(ctx);
353 * return 1 if the context is dead.
355 int cli_ctx_check_death(struct ptlrpc_cli_ctx *ctx)
357 if (unlikely(cli_ctx_is_dead(ctx)))
360 /* expire is 0 means never expire. a newly created gss context
361 * which during upcall may has 0 expiration */
362 if (ctx->cc_expire == 0)
365 /* check real expiration */
366 if (cfs_time_after(ctx->cc_expire, cfs_time_current_sec()))
373 void gss_cli_ctx_uptodate(struct gss_cli_ctx *gctx)
375 struct ptlrpc_cli_ctx *ctx = &gctx->gc_base;
376 unsigned long ctx_expiry;
378 if (lgss_inquire_context(gctx->gc_mechctx, &ctx_expiry)) {
379 CERROR("ctx %p(%u): unable to inquire, expire it now\n",
380 gctx, ctx->cc_vcred.vc_uid);
381 ctx_expiry = 1; /* make it expired now */
384 ctx->cc_expire = gss_round_ctx_expiry(ctx_expiry,
385 ctx->cc_sec->ps_flvr.sf_flags);
387 /* At this point this ctx might have been marked as dead by
388 * someone else, in which case nobody will make further use
389 * of it. we don't care, and mark it UPTODATE will help
390 * destroying server side context when it be destroied. */
391 set_bit(PTLRPC_CTX_UPTODATE_BIT, &ctx->cc_flags);
393 if (sec_is_reverse(ctx->cc_sec)) {
394 CWARN("server installed reverse ctx %p idx "LPX64", "
395 "expiry %lu(%+lds)\n", ctx,
396 gss_handle_to_u64(&gctx->gc_handle),
397 ctx->cc_expire, ctx->cc_expire - cfs_time_current_sec());
399 CWARN("client refreshed ctx %p idx "LPX64" (%u->%s), "
400 "expiry %lu(%+lds)\n", ctx,
401 gss_handle_to_u64(&gctx->gc_handle),
402 ctx->cc_vcred.vc_uid, sec2target_str(ctx->cc_sec),
403 ctx->cc_expire, ctx->cc_expire - cfs_time_current_sec());
405 /* install reverse svc ctx for root context */
406 if (ctx->cc_vcred.vc_uid == 0)
407 gss_sec_install_rctx(ctx->cc_sec->ps_import,
411 sptlrpc_cli_ctx_wakeup(ctx);
414 static void gss_cli_ctx_finalize(struct gss_cli_ctx *gctx)
416 LASSERT(gctx->gc_base.cc_sec);
418 if (gctx->gc_mechctx) {
419 lgss_delete_sec_context(&gctx->gc_mechctx);
420 gctx->gc_mechctx = NULL;
423 if (!rawobj_empty(&gctx->gc_svc_handle)) {
424 /* forward ctx: mark buddy reverse svcctx soon-expire. */
425 if (!sec_is_reverse(gctx->gc_base.cc_sec) &&
426 !rawobj_empty(&gctx->gc_svc_handle))
427 gss_svc_upcall_expire_rvs_ctx(&gctx->gc_svc_handle);
429 rawobj_free(&gctx->gc_svc_handle);
432 rawobj_free(&gctx->gc_handle);
436 * Based on sequence number algorithm as specified in RFC 2203.
438 * modified for our own problem: arriving request has valid sequence number,
439 * but unwrapping request might cost a long time, after that its sequence
440 * are not valid anymore (fall behind the window). It rarely happen, mostly
441 * under extreme load.
443 * note we should not check sequence before verify the integrity of incoming
444 * request, because just one attacking request with high sequence number might
445 * cause all following request be dropped.
447 * so here we use a multi-phase approach: prepare 2 sequence windows,
448 * "main window" for normal sequence and "back window" for fall behind sequence.
449 * and 3-phase checking mechanism:
450 * 0 - before integrity verification, perform a initial sequence checking in
451 * main window, which only try and don't actually set any bits. if the
452 * sequence is high above the window or fit in the window and the bit
453 * is 0, then accept and proceed to integrity verification. otherwise
454 * reject this sequence.
455 * 1 - after integrity verification, check in main window again. if this
456 * sequence is high above the window or fit in the window and the bit
457 * is 0, then set the bit and accept; if it fit in the window but bit
458 * already set, then reject; if it fall behind the window, then proceed
460 * 2 - check in back window. if it is high above the window or fit in the
461 * window and the bit is 0, then set the bit and accept. otherwise reject.
464 * 1: looks like a replay
468 * note phase 0 is necessary, because otherwise replay attacking request of
469 * sequence which between the 2 windows can't be detected.
471 * this mechanism can't totally solve the problem, but could help much less
472 * number of valid requests be dropped.
475 int gss_do_check_seq(unsigned long *window, __u32 win_size, __u32 *max_seq,
476 __u32 seq_num, int phase)
478 LASSERT(phase >= 0 && phase <= 2);
480 if (seq_num > *max_seq) {
482 * 1. high above the window
487 if (seq_num >= *max_seq + win_size) {
488 memset(window, 0, win_size / 8);
491 while(*max_seq < seq_num) {
493 __clear_bit((*max_seq) % win_size, window);
496 __set_bit(seq_num % win_size, window);
497 } else if (seq_num + win_size <= *max_seq) {
499 * 2. low behind the window
501 if (phase == 0 || phase == 2)
504 CWARN("seq %u is %u behind (size %d), check backup window\n",
505 seq_num, *max_seq - win_size - seq_num, win_size);
509 * 3. fit into the window
513 if (test_bit(seq_num % win_size, window))
518 if (__test_and_set_bit(seq_num % win_size, window))
527 CERROR("seq %u (%s %s window) is a replay: max %u, winsize %d\n",
529 seq_num + win_size > *max_seq ? "in" : "behind",
530 phase == 2 ? "backup " : "main",
536 * Based on sequence number algorithm as specified in RFC 2203.
538 * if @set == 0: initial check, don't set any bit in window
539 * if @sec == 1: final check, set bit in window
541 int gss_check_seq_num(struct gss_svc_seq_data *ssd, __u32 seq_num, int set)
545 spin_lock(&ssd->ssd_lock);
551 rc = gss_do_check_seq(ssd->ssd_win_main, GSS_SEQ_WIN_MAIN,
552 &ssd->ssd_max_main, seq_num, 0);
554 gss_stat_oos_record_svc(0, 1);
557 * phase 1 checking main window
559 rc = gss_do_check_seq(ssd->ssd_win_main, GSS_SEQ_WIN_MAIN,
560 &ssd->ssd_max_main, seq_num, 1);
563 gss_stat_oos_record_svc(1, 1);
569 * phase 2 checking back window
571 rc = gss_do_check_seq(ssd->ssd_win_back, GSS_SEQ_WIN_BACK,
572 &ssd->ssd_max_back, seq_num, 2);
574 gss_stat_oos_record_svc(2, 1);
576 gss_stat_oos_record_svc(2, 0);
579 spin_unlock(&ssd->ssd_lock);
583 /***************************************
585 ***************************************/
587 static inline int gss_cli_payload(struct ptlrpc_cli_ctx *ctx,
588 int msgsize, int privacy)
590 return gss_mech_payload(NULL, msgsize, privacy);
593 static int gss_cli_bulk_payload(struct ptlrpc_cli_ctx *ctx,
594 struct sptlrpc_flavor *flvr,
597 int payload = sizeof(struct ptlrpc_bulk_sec_desc);
599 LASSERT(SPTLRPC_FLVR_BULK_TYPE(flvr->sf_rpc) == SPTLRPC_BULK_DEFAULT);
601 if ((!reply && !read) || (reply && read)) {
602 switch (SPTLRPC_FLVR_BULK_SVC(flvr->sf_rpc)) {
603 case SPTLRPC_BULK_SVC_NULL:
605 case SPTLRPC_BULK_SVC_INTG:
606 payload += gss_cli_payload(ctx, 0, 0);
608 case SPTLRPC_BULK_SVC_PRIV:
609 payload += gss_cli_payload(ctx, 0, 1);
611 case SPTLRPC_BULK_SVC_AUTH:
620 int gss_cli_ctx_match(struct ptlrpc_cli_ctx *ctx, struct vfs_cred *vcred)
622 return (ctx->cc_vcred.vc_uid == vcred->vc_uid);
625 void gss_cli_ctx_flags2str(unsigned long flags, char *buf, int bufsize)
629 if (flags & PTLRPC_CTX_NEW)
630 strncat(buf, "new,", bufsize);
631 if (flags & PTLRPC_CTX_UPTODATE)
632 strncat(buf, "uptodate,", bufsize);
633 if (flags & PTLRPC_CTX_DEAD)
634 strncat(buf, "dead,", bufsize);
635 if (flags & PTLRPC_CTX_ERROR)
636 strncat(buf, "error,", bufsize);
637 if (flags & PTLRPC_CTX_CACHED)
638 strncat(buf, "cached,", bufsize);
639 if (flags & PTLRPC_CTX_ETERNAL)
640 strncat(buf, "eternal,", bufsize);
642 strncat(buf, "-,", bufsize);
644 buf[strlen(buf) - 1] = '\0';
647 int gss_cli_ctx_sign(struct ptlrpc_cli_ctx *ctx,
648 struct ptlrpc_request *req)
650 struct gss_cli_ctx *gctx = ctx2gctx(ctx);
651 __u32 flags = 0, seq, svc;
655 LASSERT(req->rq_reqbuf);
656 LASSERT(req->rq_reqbuf->lm_bufcount >= 2);
657 LASSERT(req->rq_cli_ctx == ctx);
659 /* nothing to do for context negotiation RPCs */
660 if (req->rq_ctx_init)
663 svc = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc);
664 if (req->rq_pack_bulk)
665 flags |= LUSTRE_GSS_PACK_BULK;
666 if (req->rq_pack_udesc)
667 flags |= LUSTRE_GSS_PACK_USER;
670 seq = cfs_atomic_inc_return(&gctx->gc_seq);
672 rc = gss_sign_msg(req->rq_reqbuf, gctx->gc_mechctx,
673 ctx->cc_sec->ps_part,
674 flags, gctx->gc_proc, seq, svc,
679 /* gss_sign_msg() msg might take long time to finish, in which period
680 * more rpcs could be wrapped up and sent out. if we found too many
681 * of them we should repack this rpc, because sent it too late might
682 * lead to the sequence number fall behind the window on server and
683 * be dropped. also applies to gss_cli_ctx_seal().
685 * Note: null mode dosen't check sequence number. */
686 if (svc != SPTLRPC_SVC_NULL &&
687 cfs_atomic_read(&gctx->gc_seq) - seq > GSS_SEQ_REPACK_THRESHOLD) {
688 int behind = cfs_atomic_read(&gctx->gc_seq) - seq;
690 gss_stat_oos_record_cli(behind);
691 CWARN("req %p: %u behind, retry signing\n", req, behind);
695 req->rq_reqdata_len = rc;
700 int gss_cli_ctx_handle_err_notify(struct ptlrpc_cli_ctx *ctx,
701 struct ptlrpc_request *req,
702 struct gss_header *ghdr)
704 struct gss_err_header *errhdr;
707 LASSERT(ghdr->gh_proc == PTLRPC_GSS_PROC_ERR);
709 errhdr = (struct gss_err_header *) ghdr;
711 CWARN("req x"LPU64"/t"LPU64", ctx %p idx "LPX64"(%u->%s): "
712 "%sserver respond (%08x/%08x)\n",
713 req->rq_xid, req->rq_transno, ctx,
714 gss_handle_to_u64(&ctx2gctx(ctx)->gc_handle),
715 ctx->cc_vcred.vc_uid, sec2target_str(ctx->cc_sec),
716 sec_is_reverse(ctx->cc_sec) ? "reverse" : "",
717 errhdr->gh_major, errhdr->gh_minor);
719 /* context fini rpc, let it failed */
720 if (req->rq_ctx_fini) {
721 CWARN("context fini rpc failed\n");
725 /* reverse sec, just return error, don't expire this ctx because it's
726 * crucial to callback rpcs. note if the callback rpc failed because
727 * of bit flip during network transfer, the client will be evicted
728 * directly. so more gracefully we probably want let it retry for
729 * number of times. */
730 if (sec_is_reverse(ctx->cc_sec))
733 if (errhdr->gh_major != GSS_S_NO_CONTEXT &&
734 errhdr->gh_major != GSS_S_BAD_SIG)
737 /* server return NO_CONTEXT might be caused by context expire
738 * or server reboot/failover. we try to refresh a new ctx which
739 * be transparent to upper layer.
741 * In some cases, our gss handle is possible to be incidentally
742 * identical to another handle since the handle itself is not
743 * fully random. In krb5 case, the GSS_S_BAD_SIG will be
744 * returned, maybe other gss error for other mechanism.
746 * if we add new mechanism, make sure the correct error are
747 * returned in this case. */
748 CWARN("%s: server might lost the context, retrying\n",
749 errhdr->gh_major == GSS_S_NO_CONTEXT ? "NO_CONTEXT" : "BAD_SIG");
751 sptlrpc_cli_ctx_expire(ctx);
753 /* we need replace the ctx right here, otherwise during
754 * resent we'll hit the logic in sptlrpc_req_refresh_ctx()
755 * which keep the ctx with RESEND flag, thus we'll never
756 * get rid of this ctx. */
757 rc = sptlrpc_req_replace_dead_ctx(req);
764 int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx,
765 struct ptlrpc_request *req)
767 struct gss_cli_ctx *gctx;
768 struct gss_header *ghdr, *reqhdr;
769 struct lustre_msg *msg = req->rq_repdata;
771 int pack_bulk, swabbed, rc = 0;
774 LASSERT(req->rq_cli_ctx == ctx);
777 gctx = container_of(ctx, struct gss_cli_ctx, gc_base);
779 /* special case for context negotiation, rq_repmsg/rq_replen actually
780 * are not used currently. but early reply always be treated normally */
781 if (req->rq_ctx_init && !req->rq_early) {
782 req->rq_repmsg = lustre_msg_buf(msg, 1, 0);
783 req->rq_replen = msg->lm_buflens[1];
787 if (msg->lm_bufcount < 2 || msg->lm_bufcount > 4) {
788 CERROR("unexpected bufcount %u\n", msg->lm_bufcount);
792 swabbed = ptlrpc_rep_need_swab(req);
794 ghdr = gss_swab_header(msg, 0, swabbed);
796 CERROR("can't decode gss header\n");
801 reqhdr = lustre_msg_buf(msg, 0, sizeof(*reqhdr));
804 if (ghdr->gh_version != reqhdr->gh_version) {
805 CERROR("gss version %u mismatch, expect %u\n",
806 ghdr->gh_version, reqhdr->gh_version);
810 switch (ghdr->gh_proc) {
811 case PTLRPC_GSS_PROC_DATA:
812 pack_bulk = ghdr->gh_flags & LUSTRE_GSS_PACK_BULK;
814 if (!req->rq_early && !equi(req->rq_pack_bulk == 1, pack_bulk)){
815 CERROR("%s bulk flag in reply\n",
816 req->rq_pack_bulk ? "missing" : "unexpected");
820 if (ghdr->gh_seq != reqhdr->gh_seq) {
821 CERROR("seqnum %u mismatch, expect %u\n",
822 ghdr->gh_seq, reqhdr->gh_seq);
826 if (ghdr->gh_svc != reqhdr->gh_svc) {
827 CERROR("svc %u mismatch, expect %u\n",
828 ghdr->gh_svc, reqhdr->gh_svc);
833 gss_header_swabber(ghdr);
835 major = gss_verify_msg(msg, gctx->gc_mechctx, reqhdr->gh_svc);
836 if (major != GSS_S_COMPLETE) {
837 CERROR("failed to verify reply: %x\n", major);
841 if (req->rq_early && reqhdr->gh_svc == SPTLRPC_SVC_NULL) {
844 cksum = crc32_le(!(__u32) 0,
845 lustre_msg_buf(msg, 1, 0),
846 lustre_msg_buflen(msg, 1));
847 if (cksum != msg->lm_cksum) {
848 CWARN("early reply checksum mismatch: "
849 "%08x != %08x\n", cksum, msg->lm_cksum);
855 /* bulk checksum is right after the lustre msg */
856 if (msg->lm_bufcount < 3) {
857 CERROR("Invalid reply bufcount %u\n",
862 rc = bulk_sec_desc_unpack(msg, 2, swabbed);
864 CERROR("unpack bulk desc: %d\n", rc);
869 req->rq_repmsg = lustre_msg_buf(msg, 1, 0);
870 req->rq_replen = msg->lm_buflens[1];
872 case PTLRPC_GSS_PROC_ERR:
874 CERROR("server return error with early reply\n");
877 rc = gss_cli_ctx_handle_err_notify(ctx, req, ghdr);
881 CERROR("unknown gss proc %d\n", ghdr->gh_proc);
888 int gss_cli_ctx_seal(struct ptlrpc_cli_ctx *ctx,
889 struct ptlrpc_request *req)
891 struct gss_cli_ctx *gctx;
892 rawobj_t hdrobj, msgobj, token;
893 struct gss_header *ghdr;
894 __u32 buflens[2], major;
898 LASSERT(req->rq_clrbuf);
899 LASSERT(req->rq_cli_ctx == ctx);
900 LASSERT(req->rq_reqlen);
902 gctx = container_of(ctx, struct gss_cli_ctx, gc_base);
904 /* final clear data length */
905 req->rq_clrdata_len = lustre_msg_size_v2(req->rq_clrbuf->lm_bufcount,
906 req->rq_clrbuf->lm_buflens);
908 /* calculate wire data length */
909 buflens[0] = PTLRPC_GSS_HEADER_SIZE;
910 buflens[1] = gss_cli_payload(&gctx->gc_base, req->rq_clrdata_len, 1);
911 wiresize = lustre_msg_size_v2(2, buflens);
913 /* allocate wire buffer */
916 LASSERT(req->rq_reqbuf);
917 LASSERT(req->rq_reqbuf != req->rq_clrbuf);
918 LASSERT(req->rq_reqbuf_len >= wiresize);
920 OBD_ALLOC_LARGE(req->rq_reqbuf, wiresize);
923 req->rq_reqbuf_len = wiresize;
926 lustre_init_msg_v2(req->rq_reqbuf, 2, buflens, NULL);
927 req->rq_reqbuf->lm_secflvr = req->rq_flvr.sf_rpc;
930 ghdr = lustre_msg_buf(req->rq_reqbuf, 0, 0);
931 ghdr->gh_version = PTLRPC_GSS_VERSION;
932 ghdr->gh_sp = (__u8) ctx->cc_sec->ps_part;
934 ghdr->gh_proc = gctx->gc_proc;
935 ghdr->gh_svc = SPTLRPC_SVC_PRIV;
936 ghdr->gh_handle.len = gctx->gc_handle.len;
937 memcpy(ghdr->gh_handle.data, gctx->gc_handle.data, gctx->gc_handle.len);
938 if (req->rq_pack_bulk)
939 ghdr->gh_flags |= LUSTRE_GSS_PACK_BULK;
940 if (req->rq_pack_udesc)
941 ghdr->gh_flags |= LUSTRE_GSS_PACK_USER;
944 ghdr->gh_seq = cfs_atomic_inc_return(&gctx->gc_seq);
947 hdrobj.len = PTLRPC_GSS_HEADER_SIZE;
948 hdrobj.data = (__u8 *) ghdr;
949 msgobj.len = req->rq_clrdata_len;
950 msgobj.data = (__u8 *) req->rq_clrbuf;
951 token.len = lustre_msg_buflen(req->rq_reqbuf, 1);
952 token.data = lustre_msg_buf(req->rq_reqbuf, 1, 0);
954 major = lgss_wrap(gctx->gc_mechctx, &hdrobj, &msgobj,
955 req->rq_clrbuf_len, &token);
956 if (major != GSS_S_COMPLETE) {
957 CERROR("priv: wrap message error: %08x\n", major);
958 GOTO(err_free, rc = -EPERM);
960 LASSERT(token.len <= buflens[1]);
962 /* see explain in gss_cli_ctx_sign() */
963 if (unlikely(cfs_atomic_read(&gctx->gc_seq) - ghdr->gh_seq >
964 GSS_SEQ_REPACK_THRESHOLD)) {
965 int behind = cfs_atomic_read(&gctx->gc_seq) - ghdr->gh_seq;
967 gss_stat_oos_record_cli(behind);
968 CWARN("req %p: %u behind, retry sealing\n", req, behind);
970 ghdr->gh_seq = cfs_atomic_inc_return(&gctx->gc_seq);
974 /* now set the final wire data length */
975 req->rq_reqdata_len = lustre_shrink_msg(req->rq_reqbuf, 1, token.len,0);
980 OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
981 req->rq_reqbuf = NULL;
982 req->rq_reqbuf_len = 0;
987 int gss_cli_ctx_unseal(struct ptlrpc_cli_ctx *ctx,
988 struct ptlrpc_request *req)
990 struct gss_cli_ctx *gctx;
991 struct gss_header *ghdr;
992 struct lustre_msg *msg = req->rq_repdata;
993 int msglen, pack_bulk, swabbed, rc;
997 LASSERT(req->rq_cli_ctx == ctx);
998 LASSERT(req->rq_ctx_init == 0);
1001 gctx = container_of(ctx, struct gss_cli_ctx, gc_base);
1002 swabbed = ptlrpc_rep_need_swab(req);
1004 ghdr = gss_swab_header(msg, 0, swabbed);
1006 CERROR("can't decode gss header\n");
1011 if (ghdr->gh_version != PTLRPC_GSS_VERSION) {
1012 CERROR("gss version %u mismatch, expect %u\n",
1013 ghdr->gh_version, PTLRPC_GSS_VERSION);
1017 switch (ghdr->gh_proc) {
1018 case PTLRPC_GSS_PROC_DATA:
1019 pack_bulk = ghdr->gh_flags & LUSTRE_GSS_PACK_BULK;
1021 if (!req->rq_early && !equi(req->rq_pack_bulk == 1, pack_bulk)){
1022 CERROR("%s bulk flag in reply\n",
1023 req->rq_pack_bulk ? "missing" : "unexpected");
1028 gss_header_swabber(ghdr);
1030 /* use rq_repdata_len as buffer size, which assume unseal
1031 * doesn't need extra memory space. for precise control, we'd
1032 * better calculate out actual buffer size as
1033 * (repbuf_len - offset - repdata_len) */
1034 major = gss_unseal_msg(gctx->gc_mechctx, msg,
1035 &msglen, req->rq_repdata_len);
1036 if (major != GSS_S_COMPLETE) {
1037 CERROR("failed to unwrap reply: %x\n", major);
1042 swabbed = __lustre_unpack_msg(msg, msglen);
1044 CERROR("Failed to unpack after decryption\n");
1048 if (msg->lm_bufcount < 1) {
1049 CERROR("Invalid reply buffer: empty\n");
1054 if (msg->lm_bufcount < 2) {
1055 CERROR("bufcount %u: missing bulk sec desc\n",
1060 /* bulk checksum is the last segment */
1061 if (bulk_sec_desc_unpack(msg, msg->lm_bufcount - 1,
1066 req->rq_repmsg = lustre_msg_buf(msg, 0, 0);
1067 req->rq_replen = msg->lm_buflens[0];
1071 case PTLRPC_GSS_PROC_ERR:
1072 if (req->rq_early) {
1073 CERROR("server return error with early reply\n");
1076 rc = gss_cli_ctx_handle_err_notify(ctx, req, ghdr);
1080 CERROR("unexpected proc %d\n", ghdr->gh_proc);
1087 /*********************************************
1088 * reverse context installation *
1089 *********************************************/
1092 int gss_install_rvs_svc_ctx(struct obd_import *imp,
1093 struct gss_sec *gsec,
1094 struct gss_cli_ctx *gctx)
1096 return gss_svc_upcall_install_rvs_ctx(imp, gsec, gctx);
1099 /*********************************************
1100 * GSS security APIs *
1101 *********************************************/
1102 int gss_sec_create_common(struct gss_sec *gsec,
1103 struct ptlrpc_sec_policy *policy,
1104 struct obd_import *imp,
1105 struct ptlrpc_svc_ctx *svcctx,
1106 struct sptlrpc_flavor *sf)
1108 struct ptlrpc_sec *sec;
1111 LASSERT(SPTLRPC_FLVR_POLICY(sf->sf_rpc) == SPTLRPC_POLICY_GSS);
1113 gsec->gs_mech = lgss_subflavor_to_mech(
1114 SPTLRPC_FLVR_BASE_SUB(sf->sf_rpc));
1115 if (!gsec->gs_mech) {
1116 CERROR("gss backend 0x%x not found\n",
1117 SPTLRPC_FLVR_BASE_SUB(sf->sf_rpc));
1121 spin_lock_init(&gsec->gs_lock);
1122 gsec->gs_rvs_hdl = 0ULL;
1124 /* initialize upper ptlrpc_sec */
1125 sec = &gsec->gs_base;
1126 sec->ps_policy = policy;
1127 cfs_atomic_set(&sec->ps_refcount, 0);
1128 cfs_atomic_set(&sec->ps_nctx, 0);
1129 sec->ps_id = sptlrpc_get_next_secid();
1131 sec->ps_import = class_import_get(imp);
1132 spin_lock_init(&sec->ps_lock);
1133 CFS_INIT_LIST_HEAD(&sec->ps_gc_list);
1136 sec->ps_gc_interval = GSS_GC_INTERVAL;
1138 LASSERT(sec_is_reverse(sec));
1140 /* never do gc on reverse sec */
1141 sec->ps_gc_interval = 0;
1144 if (SPTLRPC_FLVR_BULK_SVC(sec->ps_flvr.sf_rpc) == SPTLRPC_BULK_SVC_PRIV)
1145 sptlrpc_enc_pool_add_user();
1147 CDEBUG(D_SEC, "create %s%s@%p\n", (svcctx ? "reverse " : ""),
1148 policy->sp_name, gsec);
1152 void gss_sec_destroy_common(struct gss_sec *gsec)
1154 struct ptlrpc_sec *sec = &gsec->gs_base;
1157 LASSERT(sec->ps_import);
1158 LASSERT(cfs_atomic_read(&sec->ps_refcount) == 0);
1159 LASSERT(cfs_atomic_read(&sec->ps_nctx) == 0);
1161 if (gsec->gs_mech) {
1162 lgss_mech_put(gsec->gs_mech);
1163 gsec->gs_mech = NULL;
1166 class_import_put(sec->ps_import);
1168 if (SPTLRPC_FLVR_BULK_SVC(sec->ps_flvr.sf_rpc) == SPTLRPC_BULK_SVC_PRIV)
1169 sptlrpc_enc_pool_del_user();
1174 void gss_sec_kill(struct ptlrpc_sec *sec)
1179 int gss_cli_ctx_init_common(struct ptlrpc_sec *sec,
1180 struct ptlrpc_cli_ctx *ctx,
1181 struct ptlrpc_ctx_ops *ctxops,
1182 struct vfs_cred *vcred)
1184 struct gss_cli_ctx *gctx = ctx2gctx(ctx);
1187 cfs_atomic_set(&gctx->gc_seq, 0);
1189 CFS_INIT_HLIST_NODE(&ctx->cc_cache);
1190 cfs_atomic_set(&ctx->cc_refcount, 0);
1192 ctx->cc_ops = ctxops;
1194 ctx->cc_flags = PTLRPC_CTX_NEW;
1195 ctx->cc_vcred = *vcred;
1196 spin_lock_init(&ctx->cc_lock);
1197 CFS_INIT_LIST_HEAD(&ctx->cc_req_list);
1198 CFS_INIT_LIST_HEAD(&ctx->cc_gc_chain);
1200 /* take a ref on belonging sec, balanced in ctx destroying */
1201 cfs_atomic_inc(&sec->ps_refcount);
1202 /* statistic only */
1203 cfs_atomic_inc(&sec->ps_nctx);
1205 CDEBUG(D_SEC, "%s@%p: create ctx %p(%u->%s)\n",
1206 sec->ps_policy->sp_name, ctx->cc_sec,
1207 ctx, ctx->cc_vcred.vc_uid, sec2target_str(ctx->cc_sec));
1213 * 1: the context has been taken care of by someone else
1214 * 0: proceed to really destroy the context locally
1216 int gss_cli_ctx_fini_common(struct ptlrpc_sec *sec,
1217 struct ptlrpc_cli_ctx *ctx)
1219 struct gss_cli_ctx *gctx = ctx2gctx(ctx);
1221 LASSERT(cfs_atomic_read(&sec->ps_nctx) > 0);
1222 LASSERT(cfs_atomic_read(&ctx->cc_refcount) == 0);
1223 LASSERT(ctx->cc_sec == sec);
1226 * remove UPTODATE flag of reverse ctx thus we won't send fini rpc,
1227 * this is to avoid potential problems of client side reverse svc ctx
1228 * be mis-destroyed in various recovery senarios. anyway client can
1229 * manage its reverse ctx well by associating it with its buddy ctx.
1231 if (sec_is_reverse(sec))
1232 ctx->cc_flags &= ~PTLRPC_CTX_UPTODATE;
1234 if (gctx->gc_mechctx) {
1235 /* the final context fini rpc will use this ctx too, and it's
1236 * asynchronous which finished by request_out_callback(). so
1237 * we add refcount, whoever drop finally drop the refcount to
1238 * 0 should responsible for the rest of destroy. */
1239 cfs_atomic_inc(&ctx->cc_refcount);
1241 gss_do_ctx_fini_rpc(gctx);
1242 gss_cli_ctx_finalize(gctx);
1244 if (!cfs_atomic_dec_and_test(&ctx->cc_refcount))
1248 if (sec_is_reverse(sec))
1249 CWARN("reverse sec %p: destroy ctx %p\n",
1252 CWARN("%s@%p: destroy ctx %p(%u->%s)\n",
1253 sec->ps_policy->sp_name, ctx->cc_sec,
1254 ctx, ctx->cc_vcred.vc_uid, sec2target_str(ctx->cc_sec));
1260 int gss_alloc_reqbuf_intg(struct ptlrpc_sec *sec,
1261 struct ptlrpc_request *req,
1262 int svc, int msgsize)
1264 int bufsize, txtsize;
1270 * on-wire data layout:
1273 * - user descriptor (optional)
1274 * - bulk sec descriptor (optional)
1275 * - signature (optional)
1276 * - svc == NULL: NULL
1277 * - svc == AUTH: signature of gss header
1278 * - svc == INTG: signature of all above
1280 * if this is context negotiation, reserver fixed space
1281 * at the last (signature) segment regardless of svc mode.
1284 buflens[0] = PTLRPC_GSS_HEADER_SIZE;
1285 txtsize = buflens[0];
1287 buflens[1] = msgsize;
1288 if (svc == SPTLRPC_SVC_INTG)
1289 txtsize += buflens[1];
1291 if (req->rq_pack_udesc) {
1292 buflens[bufcnt] = sptlrpc_current_user_desc_size();
1293 if (svc == SPTLRPC_SVC_INTG)
1294 txtsize += buflens[bufcnt];
1298 if (req->rq_pack_bulk) {
1299 buflens[bufcnt] = gss_cli_bulk_payload(req->rq_cli_ctx,
1301 0, req->rq_bulk_read);
1302 if (svc == SPTLRPC_SVC_INTG)
1303 txtsize += buflens[bufcnt];
1307 if (req->rq_ctx_init)
1308 buflens[bufcnt++] = GSS_CTX_INIT_MAX_LEN;
1309 else if (svc != SPTLRPC_SVC_NULL)
1310 buflens[bufcnt++] = gss_cli_payload(req->rq_cli_ctx, txtsize,0);
1312 bufsize = lustre_msg_size_v2(bufcnt, buflens);
1314 if (!req->rq_reqbuf) {
1315 bufsize = size_roundup_power2(bufsize);
1317 OBD_ALLOC_LARGE(req->rq_reqbuf, bufsize);
1318 if (!req->rq_reqbuf)
1321 req->rq_reqbuf_len = bufsize;
1323 LASSERT(req->rq_pool);
1324 LASSERT(req->rq_reqbuf_len >= bufsize);
1325 memset(req->rq_reqbuf, 0, bufsize);
1328 lustre_init_msg_v2(req->rq_reqbuf, bufcnt, buflens, NULL);
1329 req->rq_reqbuf->lm_secflvr = req->rq_flvr.sf_rpc;
1331 req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, 1, msgsize);
1332 LASSERT(req->rq_reqmsg);
1334 /* pack user desc here, later we might leave current user's process */
1335 if (req->rq_pack_udesc)
1336 sptlrpc_pack_user_desc(req->rq_reqbuf, 2);
1342 int gss_alloc_reqbuf_priv(struct ptlrpc_sec *sec,
1343 struct ptlrpc_request *req,
1346 __u32 ibuflens[3], wbuflens[2];
1348 int clearsize, wiresize;
1351 LASSERT(req->rq_clrbuf == NULL);
1352 LASSERT(req->rq_clrbuf_len == 0);
1354 /* Inner (clear) buffers
1356 * - user descriptor (optional)
1357 * - bulk checksum (optional)
1360 ibuflens[0] = msgsize;
1362 if (req->rq_pack_udesc)
1363 ibuflens[ibufcnt++] = sptlrpc_current_user_desc_size();
1364 if (req->rq_pack_bulk)
1365 ibuflens[ibufcnt++] = gss_cli_bulk_payload(req->rq_cli_ctx,
1369 clearsize = lustre_msg_size_v2(ibufcnt, ibuflens);
1370 /* to allow append padding during encryption */
1371 clearsize += GSS_MAX_CIPHER_BLOCK;
1373 /* Wrapper (wire) buffers
1377 wbuflens[0] = PTLRPC_GSS_HEADER_SIZE;
1378 wbuflens[1] = gss_cli_payload(req->rq_cli_ctx, clearsize, 1);
1379 wiresize = lustre_msg_size_v2(2, wbuflens);
1382 /* rq_reqbuf is preallocated */
1383 LASSERT(req->rq_reqbuf);
1384 LASSERT(req->rq_reqbuf_len >= wiresize);
1386 memset(req->rq_reqbuf, 0, req->rq_reqbuf_len);
1388 /* if the pre-allocated buffer is big enough, we just pack
1389 * both clear buf & request buf in it, to avoid more alloc. */
1390 if (clearsize + wiresize <= req->rq_reqbuf_len) {
1392 (void *) (((char *) req->rq_reqbuf) + wiresize);
1394 CWARN("pre-allocated buf size %d is not enough for "
1395 "both clear (%d) and cipher (%d) text, proceed "
1396 "with extra allocation\n", req->rq_reqbuf_len,
1397 clearsize, wiresize);
1401 if (!req->rq_clrbuf) {
1402 clearsize = size_roundup_power2(clearsize);
1404 OBD_ALLOC_LARGE(req->rq_clrbuf, clearsize);
1405 if (!req->rq_clrbuf)
1408 req->rq_clrbuf_len = clearsize;
1410 lustre_init_msg_v2(req->rq_clrbuf, ibufcnt, ibuflens, NULL);
1411 req->rq_reqmsg = lustre_msg_buf(req->rq_clrbuf, 0, msgsize);
1413 if (req->rq_pack_udesc)
1414 sptlrpc_pack_user_desc(req->rq_clrbuf, 1);
1420 * NOTE: any change of request buffer allocation should also consider
1421 * changing enlarge_reqbuf() series functions.
1423 int gss_alloc_reqbuf(struct ptlrpc_sec *sec,
1424 struct ptlrpc_request *req,
1427 int svc = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc);
1429 LASSERT(!req->rq_pack_bulk ||
1430 (req->rq_bulk_read || req->rq_bulk_write));
1433 case SPTLRPC_SVC_NULL:
1434 case SPTLRPC_SVC_AUTH:
1435 case SPTLRPC_SVC_INTG:
1436 return gss_alloc_reqbuf_intg(sec, req, svc, msgsize);
1437 case SPTLRPC_SVC_PRIV:
1438 return gss_alloc_reqbuf_priv(sec, req, msgsize);
1440 LASSERTF(0, "bad rpc flavor %x\n", req->rq_flvr.sf_rpc);
1445 void gss_free_reqbuf(struct ptlrpc_sec *sec,
1446 struct ptlrpc_request *req)
1451 LASSERT(!req->rq_pool || req->rq_reqbuf);
1452 privacy = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc) == SPTLRPC_SVC_PRIV;
1454 if (!req->rq_clrbuf)
1455 goto release_reqbuf;
1457 /* release clear buffer */
1459 LASSERT(req->rq_clrbuf_len);
1461 if (req->rq_pool == NULL ||
1462 req->rq_clrbuf < req->rq_reqbuf ||
1463 (char *) req->rq_clrbuf >=
1464 (char *) req->rq_reqbuf + req->rq_reqbuf_len)
1465 OBD_FREE_LARGE(req->rq_clrbuf, req->rq_clrbuf_len);
1467 req->rq_clrbuf = NULL;
1468 req->rq_clrbuf_len = 0;
1471 if (!req->rq_pool && req->rq_reqbuf) {
1472 LASSERT(req->rq_reqbuf_len);
1474 OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
1475 req->rq_reqbuf = NULL;
1476 req->rq_reqbuf_len = 0;
1482 static int do_alloc_repbuf(struct ptlrpc_request *req, int bufsize)
1484 bufsize = size_roundup_power2(bufsize);
1486 OBD_ALLOC_LARGE(req->rq_repbuf, bufsize);
1487 if (!req->rq_repbuf)
1490 req->rq_repbuf_len = bufsize;
1495 int gss_alloc_repbuf_intg(struct ptlrpc_sec *sec,
1496 struct ptlrpc_request *req,
1497 int svc, int msgsize)
1505 * on-wire data layout:
1508 * - bulk sec descriptor (optional)
1509 * - signature (optional)
1510 * - svc == NULL: NULL
1511 * - svc == AUTH: signature of gss header
1512 * - svc == INTG: signature of all above
1514 * if this is context negotiation, reserver fixed space
1515 * at the last (signature) segment regardless of svc mode.
1518 buflens[0] = PTLRPC_GSS_HEADER_SIZE;
1519 txtsize = buflens[0];
1521 buflens[1] = msgsize;
1522 if (svc == SPTLRPC_SVC_INTG)
1523 txtsize += buflens[1];
1525 if (req->rq_pack_bulk) {
1526 buflens[bufcnt] = gss_cli_bulk_payload(req->rq_cli_ctx,
1528 1, req->rq_bulk_read);
1529 if (svc == SPTLRPC_SVC_INTG)
1530 txtsize += buflens[bufcnt];
1534 if (req->rq_ctx_init)
1535 buflens[bufcnt++] = GSS_CTX_INIT_MAX_LEN;
1536 else if (svc != SPTLRPC_SVC_NULL)
1537 buflens[bufcnt++] = gss_cli_payload(req->rq_cli_ctx, txtsize,0);
1539 alloc_size = lustre_msg_size_v2(bufcnt, buflens);
1541 /* add space for early reply */
1542 alloc_size += gss_at_reply_off_integ;
1544 return do_alloc_repbuf(req, alloc_size);
1548 int gss_alloc_repbuf_priv(struct ptlrpc_sec *sec,
1549 struct ptlrpc_request *req,
1559 buflens[0] = msgsize;
1561 if (req->rq_pack_bulk)
1562 buflens[bufcnt++] = gss_cli_bulk_payload(req->rq_cli_ctx,
1564 1, req->rq_bulk_read);
1565 txtsize = lustre_msg_size_v2(bufcnt, buflens);
1566 txtsize += GSS_MAX_CIPHER_BLOCK;
1568 /* wrapper buffers */
1570 buflens[0] = PTLRPC_GSS_HEADER_SIZE;
1571 buflens[1] = gss_cli_payload(req->rq_cli_ctx, txtsize, 1);
1573 alloc_size = lustre_msg_size_v2(bufcnt, buflens);
1574 /* add space for early reply */
1575 alloc_size += gss_at_reply_off_priv;
1577 return do_alloc_repbuf(req, alloc_size);
1580 int gss_alloc_repbuf(struct ptlrpc_sec *sec,
1581 struct ptlrpc_request *req,
1584 int svc = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc);
1587 LASSERT(!req->rq_pack_bulk ||
1588 (req->rq_bulk_read || req->rq_bulk_write));
1591 case SPTLRPC_SVC_NULL:
1592 case SPTLRPC_SVC_AUTH:
1593 case SPTLRPC_SVC_INTG:
1594 return gss_alloc_repbuf_intg(sec, req, svc, msgsize);
1595 case SPTLRPC_SVC_PRIV:
1596 return gss_alloc_repbuf_priv(sec, req, msgsize);
1598 LASSERTF(0, "bad rpc flavor %x\n", req->rq_flvr.sf_rpc);
1603 void gss_free_repbuf(struct ptlrpc_sec *sec,
1604 struct ptlrpc_request *req)
1606 OBD_FREE_LARGE(req->rq_repbuf, req->rq_repbuf_len);
1607 req->rq_repbuf = NULL;
1608 req->rq_repbuf_len = 0;
1609 req->rq_repdata = NULL;
1610 req->rq_repdata_len = 0;
1613 static int get_enlarged_msgsize(struct lustre_msg *msg,
1614 int segment, int newsize)
1616 int save, newmsg_size;
1618 LASSERT(newsize >= msg->lm_buflens[segment]);
1620 save = msg->lm_buflens[segment];
1621 msg->lm_buflens[segment] = newsize;
1622 newmsg_size = lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens);
1623 msg->lm_buflens[segment] = save;
1628 static int get_enlarged_msgsize2(struct lustre_msg *msg,
1629 int segment1, int newsize1,
1630 int segment2, int newsize2)
1632 int save1, save2, newmsg_size;
1634 LASSERT(newsize1 >= msg->lm_buflens[segment1]);
1635 LASSERT(newsize2 >= msg->lm_buflens[segment2]);
1637 save1 = msg->lm_buflens[segment1];
1638 save2 = msg->lm_buflens[segment2];
1639 msg->lm_buflens[segment1] = newsize1;
1640 msg->lm_buflens[segment2] = newsize2;
1641 newmsg_size = lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens);
1642 msg->lm_buflens[segment1] = save1;
1643 msg->lm_buflens[segment2] = save2;
1649 int gss_enlarge_reqbuf_intg(struct ptlrpc_sec *sec,
1650 struct ptlrpc_request *req,
1652 int segment, int newsize)
1654 struct lustre_msg *newbuf;
1655 int txtsize, sigsize = 0, i;
1656 int newmsg_size, newbuf_size;
1659 * gss header is at seg 0;
1660 * embedded msg is at seg 1;
1661 * signature (if any) is at the last seg
1663 LASSERT(req->rq_reqbuf);
1664 LASSERT(req->rq_reqbuf_len > req->rq_reqlen);
1665 LASSERT(req->rq_reqbuf->lm_bufcount >= 2);
1666 LASSERT(lustre_msg_buf(req->rq_reqbuf, 1, 0) == req->rq_reqmsg);
1668 /* 1. compute new embedded msg size */
1669 newmsg_size = get_enlarged_msgsize(req->rq_reqmsg, segment, newsize);
1670 LASSERT(newmsg_size >= req->rq_reqbuf->lm_buflens[1]);
1672 /* 2. compute new wrapper msg size */
1673 if (svc == SPTLRPC_SVC_NULL) {
1674 /* no signature, get size directly */
1675 newbuf_size = get_enlarged_msgsize(req->rq_reqbuf,
1678 txtsize = req->rq_reqbuf->lm_buflens[0];
1680 if (svc == SPTLRPC_SVC_INTG) {
1681 for (i = 1; i < req->rq_reqbuf->lm_bufcount; i++)
1682 txtsize += req->rq_reqbuf->lm_buflens[i];
1683 txtsize += newmsg_size - req->rq_reqbuf->lm_buflens[1];
1686 sigsize = gss_cli_payload(req->rq_cli_ctx, txtsize, 0);
1687 LASSERT(sigsize >= msg_last_seglen(req->rq_reqbuf));
1689 newbuf_size = get_enlarged_msgsize2(
1692 msg_last_segidx(req->rq_reqbuf),
1696 /* request from pool should always have enough buffer */
1697 LASSERT(!req->rq_pool || req->rq_reqbuf_len >= newbuf_size);
1699 if (req->rq_reqbuf_len < newbuf_size) {
1700 newbuf_size = size_roundup_power2(newbuf_size);
1702 OBD_ALLOC_LARGE(newbuf, newbuf_size);
1706 memcpy(newbuf, req->rq_reqbuf, req->rq_reqbuf_len);
1708 OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
1709 req->rq_reqbuf = newbuf;
1710 req->rq_reqbuf_len = newbuf_size;
1711 req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, 1, 0);
1714 /* do enlargement, from wrapper to embedded, from end to begin */
1715 if (svc != SPTLRPC_SVC_NULL)
1716 _sptlrpc_enlarge_msg_inplace(req->rq_reqbuf,
1717 msg_last_segidx(req->rq_reqbuf),
1720 _sptlrpc_enlarge_msg_inplace(req->rq_reqbuf, 1, newmsg_size);
1721 _sptlrpc_enlarge_msg_inplace(req->rq_reqmsg, segment, newsize);
1723 req->rq_reqlen = newmsg_size;
1728 int gss_enlarge_reqbuf_priv(struct ptlrpc_sec *sec,
1729 struct ptlrpc_request *req,
1730 int segment, int newsize)
1732 struct lustre_msg *newclrbuf;
1733 int newmsg_size, newclrbuf_size, newcipbuf_size;
1737 * embedded msg is at seg 0 of clear buffer;
1738 * cipher text is at seg 2 of cipher buffer;
1740 LASSERT(req->rq_pool ||
1741 (req->rq_reqbuf == NULL && req->rq_reqbuf_len == 0));
1742 LASSERT(req->rq_reqbuf == NULL ||
1743 (req->rq_pool && req->rq_reqbuf->lm_bufcount == 3));
1744 LASSERT(req->rq_clrbuf);
1745 LASSERT(req->rq_clrbuf_len > req->rq_reqlen);
1746 LASSERT(lustre_msg_buf(req->rq_clrbuf, 0, 0) == req->rq_reqmsg);
1748 /* compute new embedded msg size */
1749 newmsg_size = get_enlarged_msgsize(req->rq_reqmsg, segment, newsize);
1751 /* compute new clear buffer size */
1752 newclrbuf_size = get_enlarged_msgsize(req->rq_clrbuf, 0, newmsg_size);
1753 newclrbuf_size += GSS_MAX_CIPHER_BLOCK;
1755 /* compute new cipher buffer size */
1756 buflens[0] = PTLRPC_GSS_HEADER_SIZE;
1757 buflens[1] = gss_cli_payload(req->rq_cli_ctx, buflens[0], 0);
1758 buflens[2] = gss_cli_payload(req->rq_cli_ctx, newclrbuf_size, 1);
1759 newcipbuf_size = lustre_msg_size_v2(3, buflens);
1761 /* handle the case that we put both clear buf and cipher buf into
1762 * pre-allocated single buffer. */
1763 if (unlikely(req->rq_pool) &&
1764 req->rq_clrbuf >= req->rq_reqbuf &&
1765 (char *) req->rq_clrbuf <
1766 (char *) req->rq_reqbuf + req->rq_reqbuf_len) {
1767 /* it couldn't be better we still fit into the
1768 * pre-allocated buffer. */
1769 if (newclrbuf_size + newcipbuf_size <= req->rq_reqbuf_len) {
1772 /* move clear text backward. */
1773 src = req->rq_clrbuf;
1774 dst = (char *) req->rq_reqbuf + newcipbuf_size;
1776 memmove(dst, src, req->rq_clrbuf_len);
1778 req->rq_clrbuf = (struct lustre_msg *) dst;
1779 req->rq_clrbuf_len = newclrbuf_size;
1780 req->rq_reqmsg = lustre_msg_buf(req->rq_clrbuf, 0, 0);
1782 /* sadly we have to split out the clear buffer */
1783 LASSERT(req->rq_reqbuf_len >= newcipbuf_size);
1784 LASSERT(req->rq_clrbuf_len < newclrbuf_size);
1788 if (req->rq_clrbuf_len < newclrbuf_size) {
1789 newclrbuf_size = size_roundup_power2(newclrbuf_size);
1791 OBD_ALLOC_LARGE(newclrbuf, newclrbuf_size);
1792 if (newclrbuf == NULL)
1795 memcpy(newclrbuf, req->rq_clrbuf, req->rq_clrbuf_len);
1797 if (req->rq_reqbuf == NULL ||
1798 req->rq_clrbuf < req->rq_reqbuf ||
1799 (char *) req->rq_clrbuf >=
1800 (char *) req->rq_reqbuf + req->rq_reqbuf_len) {
1801 OBD_FREE_LARGE(req->rq_clrbuf, req->rq_clrbuf_len);
1804 req->rq_clrbuf = newclrbuf;
1805 req->rq_clrbuf_len = newclrbuf_size;
1806 req->rq_reqmsg = lustre_msg_buf(req->rq_clrbuf, 0, 0);
1809 _sptlrpc_enlarge_msg_inplace(req->rq_clrbuf, 0, newmsg_size);
1810 _sptlrpc_enlarge_msg_inplace(req->rq_reqmsg, segment, newsize);
1811 req->rq_reqlen = newmsg_size;
1816 int gss_enlarge_reqbuf(struct ptlrpc_sec *sec,
1817 struct ptlrpc_request *req,
1818 int segment, int newsize)
1820 int svc = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc);
1822 LASSERT(!req->rq_ctx_init && !req->rq_ctx_fini);
1825 case SPTLRPC_SVC_NULL:
1826 case SPTLRPC_SVC_AUTH:
1827 case SPTLRPC_SVC_INTG:
1828 return gss_enlarge_reqbuf_intg(sec, req, svc, segment, newsize);
1829 case SPTLRPC_SVC_PRIV:
1830 return gss_enlarge_reqbuf_priv(sec, req, segment, newsize);
1832 LASSERTF(0, "bad rpc flavor %x\n", req->rq_flvr.sf_rpc);
1837 int gss_sec_install_rctx(struct obd_import *imp,
1838 struct ptlrpc_sec *sec,
1839 struct ptlrpc_cli_ctx *ctx)
1841 struct gss_sec *gsec;
1842 struct gss_cli_ctx *gctx;
1845 gsec = container_of(sec, struct gss_sec, gs_base);
1846 gctx = container_of(ctx, struct gss_cli_ctx, gc_base);
1848 rc = gss_install_rvs_svc_ctx(imp, gsec, gctx);
1852 /********************************************
1854 ********************************************/
1857 int gss_svc_reqctx_is_special(struct gss_svc_reqctx *grctx)
1860 return (grctx->src_init || grctx->src_init_continue ||
1861 grctx->src_err_notify);
1865 void gss_svc_reqctx_free(struct gss_svc_reqctx *grctx)
1868 gss_svc_upcall_put_ctx(grctx->src_ctx);
1870 sptlrpc_policy_put(grctx->src_base.sc_policy);
1871 OBD_FREE_PTR(grctx);
1875 void gss_svc_reqctx_addref(struct gss_svc_reqctx *grctx)
1877 LASSERT(cfs_atomic_read(&grctx->src_base.sc_refcount) > 0);
1878 cfs_atomic_inc(&grctx->src_base.sc_refcount);
1882 void gss_svc_reqctx_decref(struct gss_svc_reqctx *grctx)
1884 LASSERT(cfs_atomic_read(&grctx->src_base.sc_refcount) > 0);
1886 if (cfs_atomic_dec_and_test(&grctx->src_base.sc_refcount))
1887 gss_svc_reqctx_free(grctx);
1891 int gss_svc_sign(struct ptlrpc_request *req,
1892 struct ptlrpc_reply_state *rs,
1893 struct gss_svc_reqctx *grctx,
1900 LASSERT(rs->rs_msg == lustre_msg_buf(rs->rs_repbuf, 1, 0));
1902 /* embedded lustre_msg might have been shrinked */
1903 if (req->rq_replen != rs->rs_repbuf->lm_buflens[1])
1904 lustre_shrink_msg(rs->rs_repbuf, 1, req->rq_replen, 1);
1906 if (req->rq_pack_bulk)
1907 flags |= LUSTRE_GSS_PACK_BULK;
1909 rc = gss_sign_msg(rs->rs_repbuf, grctx->src_ctx->gsc_mechctx,
1910 LUSTRE_SP_ANY, flags, PTLRPC_GSS_PROC_DATA,
1911 grctx->src_wirectx.gw_seq, svc, NULL);
1915 rs->rs_repdata_len = rc;
1917 if (likely(req->rq_packed_final)) {
1918 if (lustre_msghdr_get_flags(req->rq_reqmsg) & MSGHDR_AT_SUPPORT)
1919 req->rq_reply_off = gss_at_reply_off_integ;
1921 req->rq_reply_off = 0;
1923 if (svc == SPTLRPC_SVC_NULL)
1924 rs->rs_repbuf->lm_cksum = crc32_le(!(__u32) 0,
1925 lustre_msg_buf(rs->rs_repbuf, 1, 0),
1926 lustre_msg_buflen(rs->rs_repbuf, 1));
1927 req->rq_reply_off = 0;
1933 int gss_pack_err_notify(struct ptlrpc_request *req, __u32 major, __u32 minor)
1935 struct gss_svc_reqctx *grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx);
1936 struct ptlrpc_reply_state *rs;
1937 struct gss_err_header *ghdr;
1938 int replen = sizeof(struct ptlrpc_body);
1942 //if (OBD_FAIL_CHECK_ORSET(OBD_FAIL_SVCGSS_ERR_NOTIFY, OBD_FAIL_ONCE))
1945 grctx->src_err_notify = 1;
1946 grctx->src_reserve_len = 0;
1948 rc = lustre_pack_reply_v2(req, 1, &replen, NULL, 0);
1950 CERROR("could not pack reply, err %d\n", rc);
1955 rs = req->rq_reply_state;
1956 LASSERT(rs->rs_repbuf->lm_buflens[1] >= sizeof(*ghdr));
1957 ghdr = lustre_msg_buf(rs->rs_repbuf, 0, 0);
1958 ghdr->gh_version = PTLRPC_GSS_VERSION;
1960 ghdr->gh_proc = PTLRPC_GSS_PROC_ERR;
1961 ghdr->gh_major = major;
1962 ghdr->gh_minor = minor;
1963 ghdr->gh_handle.len = 0; /* fake context handle */
1965 rs->rs_repdata_len = lustre_msg_size_v2(rs->rs_repbuf->lm_bufcount,
1966 rs->rs_repbuf->lm_buflens);
1968 CDEBUG(D_SEC, "prepare gss error notify(0x%x/0x%x) to %s\n",
1969 major, minor, libcfs_nid2str(req->rq_peer.nid));
1974 int gss_svc_handle_init(struct ptlrpc_request *req,
1975 struct gss_wire_ctx *gw)
1977 struct gss_svc_reqctx *grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx);
1978 struct lustre_msg *reqbuf = req->rq_reqbuf;
1979 struct obd_uuid *uuid;
1980 struct obd_device *target;
1981 rawobj_t uuid_obj, rvs_hdl, in_token;
1983 __u32 *secdata, seclen;
1987 CDEBUG(D_SEC, "processing gss init(%d) request from %s\n", gw->gw_proc,
1988 libcfs_nid2str(req->rq_peer.nid));
1990 req->rq_ctx_init = 1;
1992 if (gw->gw_flags & LUSTRE_GSS_PACK_BULK) {
1993 CERROR("unexpected bulk flag\n");
1994 RETURN(SECSVC_DROP);
1997 if (gw->gw_proc == PTLRPC_GSS_PROC_INIT && gw->gw_handle.len != 0) {
1998 CERROR("proc %u: invalid handle length %u\n",
1999 gw->gw_proc, gw->gw_handle.len);
2000 RETURN(SECSVC_DROP);
2003 if (reqbuf->lm_bufcount < 3 || reqbuf->lm_bufcount > 4){
2004 CERROR("Invalid bufcount %d\n", reqbuf->lm_bufcount);
2005 RETURN(SECSVC_DROP);
2008 swabbed = ptlrpc_req_need_swab(req);
2010 /* ctx initiate payload is in last segment */
2011 secdata = lustre_msg_buf(reqbuf, reqbuf->lm_bufcount - 1, 0);
2012 seclen = reqbuf->lm_buflens[reqbuf->lm_bufcount - 1];
2014 if (seclen < 4 + 4) {
2015 CERROR("sec size %d too small\n", seclen);
2016 RETURN(SECSVC_DROP);
2019 /* lustre svc type */
2020 lustre_svc = le32_to_cpu(*secdata++);
2023 /* extract target uuid, note this code is somewhat fragile
2024 * because touched internal structure of obd_uuid */
2025 if (rawobj_extract(&uuid_obj, &secdata, &seclen)) {
2026 CERROR("failed to extract target uuid\n");
2027 RETURN(SECSVC_DROP);
2029 uuid_obj.data[uuid_obj.len - 1] = '\0';
2031 uuid = (struct obd_uuid *) uuid_obj.data;
2032 target = class_uuid2obd(uuid);
2033 if (!target || target->obd_stopping || !target->obd_set_up) {
2034 CERROR("target '%s' is not available for context init (%s)\n",
2035 uuid->uuid, target == NULL ? "no target" :
2036 (target->obd_stopping ? "stopping" : "not set up"));
2037 RETURN(SECSVC_DROP);
2040 /* extract reverse handle */
2041 if (rawobj_extract(&rvs_hdl, &secdata, &seclen)) {
2042 CERROR("failed extract reverse handle\n");
2043 RETURN(SECSVC_DROP);
2047 if (rawobj_extract(&in_token, &secdata, &seclen)) {
2048 CERROR("can't extract token\n");
2049 RETURN(SECSVC_DROP);
2052 rc = gss_svc_upcall_handle_init(req, grctx, gw, target, lustre_svc,
2053 &rvs_hdl, &in_token);
2054 if (rc != SECSVC_OK)
2057 if (grctx->src_ctx->gsc_usr_mds || grctx->src_ctx->gsc_usr_oss ||
2058 grctx->src_ctx->gsc_usr_root)
2059 CWARN("create svc ctx %p: user from %s authenticated as %s\n",
2060 grctx->src_ctx, libcfs_nid2str(req->rq_peer.nid),
2061 grctx->src_ctx->gsc_usr_mds ? "mds" :
2062 (grctx->src_ctx->gsc_usr_oss ? "oss" : "root"));
2064 CWARN("create svc ctx %p: accept user %u from %s\n",
2065 grctx->src_ctx, grctx->src_ctx->gsc_uid,
2066 libcfs_nid2str(req->rq_peer.nid));
2068 if (gw->gw_flags & LUSTRE_GSS_PACK_USER) {
2069 if (reqbuf->lm_bufcount < 4) {
2070 CERROR("missing user descriptor\n");
2071 RETURN(SECSVC_DROP);
2073 if (sptlrpc_unpack_user_desc(reqbuf, 2, swabbed)) {
2074 CERROR("Mal-formed user descriptor\n");
2075 RETURN(SECSVC_DROP);
2078 req->rq_pack_udesc = 1;
2079 req->rq_user_desc = lustre_msg_buf(reqbuf, 2, 0);
2082 req->rq_reqmsg = lustre_msg_buf(reqbuf, 1, 0);
2083 req->rq_reqlen = lustre_msg_buflen(reqbuf, 1);
2089 * last segment must be the gss signature.
2092 int gss_svc_verify_request(struct ptlrpc_request *req,
2093 struct gss_svc_reqctx *grctx,
2094 struct gss_wire_ctx *gw,
2097 struct gss_svc_ctx *gctx = grctx->src_ctx;
2098 struct lustre_msg *msg = req->rq_reqbuf;
2103 *major = GSS_S_COMPLETE;
2105 if (msg->lm_bufcount < 2) {
2106 CERROR("Too few segments (%u) in request\n", msg->lm_bufcount);
2110 if (gw->gw_svc == SPTLRPC_SVC_NULL)
2113 if (gss_check_seq_num(&gctx->gsc_seqdata, gw->gw_seq, 0)) {
2114 CERROR("phase 0: discard replayed req: seq %u\n", gw->gw_seq);
2115 *major = GSS_S_DUPLICATE_TOKEN;
2119 *major = gss_verify_msg(msg, gctx->gsc_mechctx, gw->gw_svc);
2120 if (*major != GSS_S_COMPLETE) {
2121 CERROR("failed to verify request: %x\n", *major);
2125 if (gctx->gsc_reverse == 0 &&
2126 gss_check_seq_num(&gctx->gsc_seqdata, gw->gw_seq, 1)) {
2127 CERROR("phase 1+: discard replayed req: seq %u\n", gw->gw_seq);
2128 *major = GSS_S_DUPLICATE_TOKEN;
2133 swabbed = ptlrpc_req_need_swab(req);
2135 /* user descriptor */
2136 if (gw->gw_flags & LUSTRE_GSS_PACK_USER) {
2137 if (msg->lm_bufcount < (offset + 1)) {
2138 CERROR("no user desc included\n");
2142 if (sptlrpc_unpack_user_desc(msg, offset, swabbed)) {
2143 CERROR("Mal-formed user descriptor\n");
2147 req->rq_pack_udesc = 1;
2148 req->rq_user_desc = lustre_msg_buf(msg, offset, 0);
2152 /* check bulk_sec_desc data */
2153 if (gw->gw_flags & LUSTRE_GSS_PACK_BULK) {
2154 if (msg->lm_bufcount < (offset + 1)) {
2155 CERROR("missing bulk sec descriptor\n");
2159 if (bulk_sec_desc_unpack(msg, offset, swabbed))
2162 req->rq_pack_bulk = 1;
2163 grctx->src_reqbsd = lustre_msg_buf(msg, offset, 0);
2164 grctx->src_reqbsd_size = lustre_msg_buflen(msg, offset);
2167 req->rq_reqmsg = lustre_msg_buf(msg, 1, 0);
2168 req->rq_reqlen = msg->lm_buflens[1];
2173 int gss_svc_unseal_request(struct ptlrpc_request *req,
2174 struct gss_svc_reqctx *grctx,
2175 struct gss_wire_ctx *gw,
2178 struct gss_svc_ctx *gctx = grctx->src_ctx;
2179 struct lustre_msg *msg = req->rq_reqbuf;
2180 int swabbed, msglen, offset = 1;
2183 if (gss_check_seq_num(&gctx->gsc_seqdata, gw->gw_seq, 0)) {
2184 CERROR("phase 0: discard replayed req: seq %u\n", gw->gw_seq);
2185 *major = GSS_S_DUPLICATE_TOKEN;
2189 *major = gss_unseal_msg(gctx->gsc_mechctx, msg,
2190 &msglen, req->rq_reqdata_len);
2191 if (*major != GSS_S_COMPLETE) {
2192 CERROR("failed to unwrap request: %x\n", *major);
2196 if (gss_check_seq_num(&gctx->gsc_seqdata, gw->gw_seq, 1)) {
2197 CERROR("phase 1+: discard replayed req: seq %u\n", gw->gw_seq);
2198 *major = GSS_S_DUPLICATE_TOKEN;
2202 swabbed = __lustre_unpack_msg(msg, msglen);
2204 CERROR("Failed to unpack after decryption\n");
2207 req->rq_reqdata_len = msglen;
2209 if (msg->lm_bufcount < 1) {
2210 CERROR("Invalid buffer: is empty\n");
2214 if (gw->gw_flags & LUSTRE_GSS_PACK_USER) {
2215 if (msg->lm_bufcount < offset + 1) {
2216 CERROR("no user descriptor included\n");
2220 if (sptlrpc_unpack_user_desc(msg, offset, swabbed)) {
2221 CERROR("Mal-formed user descriptor\n");
2225 req->rq_pack_udesc = 1;
2226 req->rq_user_desc = lustre_msg_buf(msg, offset, 0);
2230 if (gw->gw_flags & LUSTRE_GSS_PACK_BULK) {
2231 if (msg->lm_bufcount < offset + 1) {
2232 CERROR("no bulk checksum included\n");
2236 if (bulk_sec_desc_unpack(msg, offset, swabbed))
2239 req->rq_pack_bulk = 1;
2240 grctx->src_reqbsd = lustre_msg_buf(msg, offset, 0);
2241 grctx->src_reqbsd_size = lustre_msg_buflen(msg, offset);
2244 req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, 0, 0);
2245 req->rq_reqlen = req->rq_reqbuf->lm_buflens[0];
2250 int gss_svc_handle_data(struct ptlrpc_request *req,
2251 struct gss_wire_ctx *gw)
2253 struct gss_svc_reqctx *grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx);
2258 grctx->src_ctx = gss_svc_upcall_get_ctx(req, gw);
2259 if (!grctx->src_ctx) {
2260 major = GSS_S_NO_CONTEXT;
2264 switch (gw->gw_svc) {
2265 case SPTLRPC_SVC_NULL:
2266 case SPTLRPC_SVC_AUTH:
2267 case SPTLRPC_SVC_INTG:
2268 rc = gss_svc_verify_request(req, grctx, gw, &major);
2270 case SPTLRPC_SVC_PRIV:
2271 rc = gss_svc_unseal_request(req, grctx, gw, &major);
2274 CERROR("unsupported gss service %d\n", gw->gw_svc);
2281 CERROR("svc %u failed: major 0x%08x: req xid "LPU64" ctx %p idx "
2282 LPX64"(%u->%s)\n", gw->gw_svc, major, req->rq_xid,
2283 grctx->src_ctx, gss_handle_to_u64(&gw->gw_handle),
2284 grctx->src_ctx->gsc_uid, libcfs_nid2str(req->rq_peer.nid));
2286 /* we only notify client in case of NO_CONTEXT/BAD_SIG, which
2287 * might happen after server reboot, to allow recovery. */
2288 if ((major == GSS_S_NO_CONTEXT || major == GSS_S_BAD_SIG) &&
2289 gss_pack_err_notify(req, major, 0) == 0)
2290 RETURN(SECSVC_COMPLETE);
2292 RETURN(SECSVC_DROP);
2296 int gss_svc_handle_destroy(struct ptlrpc_request *req,
2297 struct gss_wire_ctx *gw)
2299 struct gss_svc_reqctx *grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx);
2303 req->rq_ctx_fini = 1;
2304 req->rq_no_reply = 1;
2306 grctx->src_ctx = gss_svc_upcall_get_ctx(req, gw);
2307 if (!grctx->src_ctx) {
2308 CDEBUG(D_SEC, "invalid gss context handle for destroy.\n");
2309 RETURN(SECSVC_DROP);
2312 if (gw->gw_svc != SPTLRPC_SVC_INTG) {
2313 CERROR("svc %u is not supported in destroy.\n", gw->gw_svc);
2314 RETURN(SECSVC_DROP);
2317 if (gss_svc_verify_request(req, grctx, gw, &major))
2318 RETURN(SECSVC_DROP);
2320 CWARN("destroy svc ctx %p idx "LPX64" (%u->%s)\n",
2321 grctx->src_ctx, gss_handle_to_u64(&gw->gw_handle),
2322 grctx->src_ctx->gsc_uid, libcfs_nid2str(req->rq_peer.nid));
2324 gss_svc_upcall_destroy_ctx(grctx->src_ctx);
2326 if (gw->gw_flags & LUSTRE_GSS_PACK_USER) {
2327 if (req->rq_reqbuf->lm_bufcount < 4) {
2328 CERROR("missing user descriptor, ignore it\n");
2331 if (sptlrpc_unpack_user_desc(req->rq_reqbuf, 2,
2332 ptlrpc_req_need_swab(req))) {
2333 CERROR("Mal-formed user descriptor, ignore it\n");
2337 req->rq_pack_udesc = 1;
2338 req->rq_user_desc = lustre_msg_buf(req->rq_reqbuf, 2, 0);
2344 int gss_svc_accept(struct ptlrpc_sec_policy *policy, struct ptlrpc_request *req)
2346 struct gss_header *ghdr;
2347 struct gss_svc_reqctx *grctx;
2348 struct gss_wire_ctx *gw;
2352 LASSERT(req->rq_reqbuf);
2353 LASSERT(req->rq_svc_ctx == NULL);
2355 if (req->rq_reqbuf->lm_bufcount < 2) {
2356 CERROR("buf count only %d\n", req->rq_reqbuf->lm_bufcount);
2357 RETURN(SECSVC_DROP);
2360 swabbed = ptlrpc_req_need_swab(req);
2362 ghdr = gss_swab_header(req->rq_reqbuf, 0, swabbed);
2364 CERROR("can't decode gss header\n");
2365 RETURN(SECSVC_DROP);
2369 if (ghdr->gh_version != PTLRPC_GSS_VERSION) {
2370 CERROR("gss version %u, expect %u\n", ghdr->gh_version,
2371 PTLRPC_GSS_VERSION);
2372 RETURN(SECSVC_DROP);
2375 req->rq_sp_from = ghdr->gh_sp;
2377 /* alloc grctx data */
2378 OBD_ALLOC_PTR(grctx);
2380 RETURN(SECSVC_DROP);
2382 grctx->src_base.sc_policy = sptlrpc_policy_get(policy);
2383 cfs_atomic_set(&grctx->src_base.sc_refcount, 1);
2384 req->rq_svc_ctx = &grctx->src_base;
2385 gw = &grctx->src_wirectx;
2387 /* save wire context */
2388 gw->gw_flags = ghdr->gh_flags;
2389 gw->gw_proc = ghdr->gh_proc;
2390 gw->gw_seq = ghdr->gh_seq;
2391 gw->gw_svc = ghdr->gh_svc;
2392 rawobj_from_netobj(&gw->gw_handle, &ghdr->gh_handle);
2394 /* keep original wire header which subject to checksum verification */
2396 gss_header_swabber(ghdr);
2398 switch(ghdr->gh_proc) {
2399 case PTLRPC_GSS_PROC_INIT:
2400 case PTLRPC_GSS_PROC_CONTINUE_INIT:
2401 rc = gss_svc_handle_init(req, gw);
2403 case PTLRPC_GSS_PROC_DATA:
2404 rc = gss_svc_handle_data(req, gw);
2406 case PTLRPC_GSS_PROC_DESTROY:
2407 rc = gss_svc_handle_destroy(req, gw);
2410 CERROR("unknown proc %u\n", gw->gw_proc);
2417 LASSERT (grctx->src_ctx);
2419 req->rq_auth_gss = 1;
2420 req->rq_auth_remote = grctx->src_ctx->gsc_remote;
2421 req->rq_auth_usr_mdt = grctx->src_ctx->gsc_usr_mds;
2422 req->rq_auth_usr_ost = grctx->src_ctx->gsc_usr_oss;
2423 req->rq_auth_usr_root = grctx->src_ctx->gsc_usr_root;
2424 req->rq_auth_uid = grctx->src_ctx->gsc_uid;
2425 req->rq_auth_mapped_uid = grctx->src_ctx->gsc_mapped_uid;
2427 case SECSVC_COMPLETE:
2430 gss_svc_reqctx_free(grctx);
2431 req->rq_svc_ctx = NULL;
2438 void gss_svc_invalidate_ctx(struct ptlrpc_svc_ctx *svc_ctx)
2440 struct gss_svc_reqctx *grctx;
2443 if (svc_ctx == NULL) {
2448 grctx = gss_svc_ctx2reqctx(svc_ctx);
2450 CWARN("gss svc invalidate ctx %p(%u)\n",
2451 grctx->src_ctx, grctx->src_ctx->gsc_uid);
2452 gss_svc_upcall_destroy_ctx(grctx->src_ctx);
2458 int gss_svc_payload(struct gss_svc_reqctx *grctx, int early,
2459 int msgsize, int privacy)
2461 /* we should treat early reply normally, but which is actually sharing
2462 * the same ctx with original request, so in this case we should
2463 * ignore the special ctx's special flags */
2464 if (early == 0 && gss_svc_reqctx_is_special(grctx))
2465 return grctx->src_reserve_len;
2467 return gss_mech_payload(NULL, msgsize, privacy);
2470 static int gss_svc_bulk_payload(struct gss_svc_ctx *gctx,
2471 struct sptlrpc_flavor *flvr,
2474 int payload = sizeof(struct ptlrpc_bulk_sec_desc);
2477 switch (SPTLRPC_FLVR_BULK_SVC(flvr->sf_rpc)) {
2478 case SPTLRPC_BULK_SVC_NULL:
2480 case SPTLRPC_BULK_SVC_INTG:
2481 payload += gss_mech_payload(NULL, 0, 0);
2483 case SPTLRPC_BULK_SVC_PRIV:
2484 payload += gss_mech_payload(NULL, 0, 1);
2486 case SPTLRPC_BULK_SVC_AUTH:
2495 int gss_svc_alloc_rs(struct ptlrpc_request *req, int msglen)
2497 struct gss_svc_reqctx *grctx;
2498 struct ptlrpc_reply_state *rs;
2499 int early, privacy, svc, bsd_off = 0;
2500 __u32 ibuflens[2], buflens[4];
2501 int ibufcnt = 0, bufcnt;
2502 int txtsize, wmsg_size, rs_size;
2505 LASSERT(msglen % 8 == 0);
2507 if (req->rq_pack_bulk && !req->rq_bulk_read && !req->rq_bulk_write) {
2508 CERROR("client request bulk sec on non-bulk rpc\n");
2512 svc = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc);
2513 early = (req->rq_packed_final == 0);
2515 grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx);
2516 if (!early && gss_svc_reqctx_is_special(grctx))
2519 privacy = (svc == SPTLRPC_SVC_PRIV);
2522 /* inner clear buffers */
2524 ibuflens[0] = msglen;
2526 if (req->rq_pack_bulk) {
2527 LASSERT(grctx->src_reqbsd);
2530 ibuflens[ibufcnt++] = gss_svc_bulk_payload(
2536 txtsize = lustre_msg_size_v2(ibufcnt, ibuflens);
2537 txtsize += GSS_MAX_CIPHER_BLOCK;
2539 /* wrapper buffer */
2541 buflens[0] = PTLRPC_GSS_HEADER_SIZE;
2542 buflens[1] = gss_svc_payload(grctx, early, txtsize, 1);
2545 buflens[0] = PTLRPC_GSS_HEADER_SIZE;
2546 buflens[1] = msglen;
2548 txtsize = buflens[0];
2549 if (svc == SPTLRPC_SVC_INTG)
2550 txtsize += buflens[1];
2552 if (req->rq_pack_bulk) {
2553 LASSERT(grctx->src_reqbsd);
2556 buflens[bufcnt] = gss_svc_bulk_payload(
2560 if (svc == SPTLRPC_SVC_INTG)
2561 txtsize += buflens[bufcnt];
2565 if ((!early && gss_svc_reqctx_is_special(grctx)) ||
2566 svc != SPTLRPC_SVC_NULL)
2567 buflens[bufcnt++] = gss_svc_payload(grctx, early,
2571 wmsg_size = lustre_msg_size_v2(bufcnt, buflens);
2573 rs_size = sizeof(*rs) + wmsg_size;
2574 rs = req->rq_reply_state;
2578 LASSERT(rs->rs_size >= rs_size);
2580 OBD_ALLOC_LARGE(rs, rs_size);
2584 rs->rs_size = rs_size;
2587 rs->rs_repbuf = (struct lustre_msg *) (rs + 1);
2588 rs->rs_repbuf_len = wmsg_size;
2590 /* initialize the buffer */
2592 lustre_init_msg_v2(rs->rs_repbuf, ibufcnt, ibuflens, NULL);
2593 rs->rs_msg = lustre_msg_buf(rs->rs_repbuf, 0, msglen);
2595 lustre_init_msg_v2(rs->rs_repbuf, bufcnt, buflens, NULL);
2596 rs->rs_repbuf->lm_secflvr = req->rq_flvr.sf_rpc;
2598 rs->rs_msg = lustre_msg_buf(rs->rs_repbuf, 1, 0);
2602 grctx->src_repbsd = lustre_msg_buf(rs->rs_repbuf, bsd_off, 0);
2603 grctx->src_repbsd_size = lustre_msg_buflen(rs->rs_repbuf,
2607 gss_svc_reqctx_addref(grctx);
2608 rs->rs_svc_ctx = req->rq_svc_ctx;
2610 LASSERT(rs->rs_msg);
2611 req->rq_reply_state = rs;
2615 static int gss_svc_seal(struct ptlrpc_request *req,
2616 struct ptlrpc_reply_state *rs,
2617 struct gss_svc_reqctx *grctx)
2619 struct gss_svc_ctx *gctx = grctx->src_ctx;
2620 rawobj_t hdrobj, msgobj, token;
2621 struct gss_header *ghdr;
2624 __u32 buflens[2], major;
2628 /* get clear data length. note embedded lustre_msg might
2629 * have been shrinked */
2630 if (req->rq_replen != lustre_msg_buflen(rs->rs_repbuf, 0))
2631 msglen = lustre_shrink_msg(rs->rs_repbuf, 0, req->rq_replen, 1);
2633 msglen = lustre_msg_size_v2(rs->rs_repbuf->lm_bufcount,
2634 rs->rs_repbuf->lm_buflens);
2636 /* temporarily use tail of buffer to hold gss header data */
2637 LASSERT(msglen + PTLRPC_GSS_HEADER_SIZE <= rs->rs_repbuf_len);
2638 ghdr = (struct gss_header *) ((char *) rs->rs_repbuf +
2639 rs->rs_repbuf_len - PTLRPC_GSS_HEADER_SIZE);
2640 ghdr->gh_version = PTLRPC_GSS_VERSION;
2641 ghdr->gh_sp = LUSTRE_SP_ANY;
2643 ghdr->gh_proc = PTLRPC_GSS_PROC_DATA;
2644 ghdr->gh_seq = grctx->src_wirectx.gw_seq;
2645 ghdr->gh_svc = SPTLRPC_SVC_PRIV;
2646 ghdr->gh_handle.len = 0;
2647 if (req->rq_pack_bulk)
2648 ghdr->gh_flags |= LUSTRE_GSS_PACK_BULK;
2650 /* allocate temporary cipher buffer */
2651 token_buflen = gss_mech_payload(gctx->gsc_mechctx, msglen, 1);
2652 OBD_ALLOC_LARGE(token_buf, token_buflen);
2653 if (token_buf == NULL)
2656 hdrobj.len = PTLRPC_GSS_HEADER_SIZE;
2657 hdrobj.data = (__u8 *) ghdr;
2658 msgobj.len = msglen;
2659 msgobj.data = (__u8 *) rs->rs_repbuf;
2660 token.len = token_buflen;
2661 token.data = token_buf;
2663 major = lgss_wrap(gctx->gsc_mechctx, &hdrobj, &msgobj,
2664 rs->rs_repbuf_len - PTLRPC_GSS_HEADER_SIZE, &token);
2665 if (major != GSS_S_COMPLETE) {
2666 CERROR("wrap message error: %08x\n", major);
2667 GOTO(out_free, rc = -EPERM);
2669 LASSERT(token.len <= token_buflen);
2671 /* we are about to override data at rs->rs_repbuf, nullify pointers
2672 * to which to catch further illegal usage. */
2673 if (req->rq_pack_bulk) {
2674 grctx->src_repbsd = NULL;
2675 grctx->src_repbsd_size = 0;
2678 /* now fill the actual wire data
2682 buflens[0] = PTLRPC_GSS_HEADER_SIZE;
2683 buflens[1] = token.len;
2685 rs->rs_repdata_len = lustre_msg_size_v2(2, buflens);
2686 LASSERT(rs->rs_repdata_len <= rs->rs_repbuf_len);
2688 lustre_init_msg_v2(rs->rs_repbuf, 2, buflens, NULL);
2689 rs->rs_repbuf->lm_secflvr = req->rq_flvr.sf_rpc;
2691 memcpy(lustre_msg_buf(rs->rs_repbuf, 0, 0), ghdr,
2692 PTLRPC_GSS_HEADER_SIZE);
2693 memcpy(lustre_msg_buf(rs->rs_repbuf, 1, 0), token.data, token.len);
2696 if (req->rq_packed_final &&
2697 (lustre_msghdr_get_flags(req->rq_reqmsg) & MSGHDR_AT_SUPPORT))
2698 req->rq_reply_off = gss_at_reply_off_priv;
2700 req->rq_reply_off = 0;
2702 /* to catch upper layer's further access */
2704 req->rq_repmsg = NULL;
2709 OBD_FREE_LARGE(token_buf, token_buflen);
2713 int gss_svc_authorize(struct ptlrpc_request *req)
2715 struct ptlrpc_reply_state *rs = req->rq_reply_state;
2716 struct gss_svc_reqctx *grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx);
2717 struct gss_wire_ctx *gw = &grctx->src_wirectx;
2721 early = (req->rq_packed_final == 0);
2723 if (!early && gss_svc_reqctx_is_special(grctx)) {
2724 LASSERT(rs->rs_repdata_len != 0);
2726 req->rq_reply_off = gss_at_reply_off_integ;
2730 /* early reply could happen in many cases */
2732 gw->gw_proc != PTLRPC_GSS_PROC_DATA &&
2733 gw->gw_proc != PTLRPC_GSS_PROC_DESTROY) {
2734 CERROR("proc %d not support\n", gw->gw_proc);
2738 LASSERT(grctx->src_ctx);
2740 switch (gw->gw_svc) {
2741 case SPTLRPC_SVC_NULL:
2742 case SPTLRPC_SVC_AUTH:
2743 case SPTLRPC_SVC_INTG:
2744 rc = gss_svc_sign(req, rs, grctx, gw->gw_svc);
2746 case SPTLRPC_SVC_PRIV:
2747 rc = gss_svc_seal(req, rs, grctx);
2750 CERROR("Unknown service %d\n", gw->gw_svc);
2751 GOTO(out, rc = -EINVAL);
2759 void gss_svc_free_rs(struct ptlrpc_reply_state *rs)
2761 struct gss_svc_reqctx *grctx;
2763 LASSERT(rs->rs_svc_ctx);
2764 grctx = container_of(rs->rs_svc_ctx, struct gss_svc_reqctx, src_base);
2766 gss_svc_reqctx_decref(grctx);
2767 rs->rs_svc_ctx = NULL;
2769 if (!rs->rs_prealloc)
2770 OBD_FREE_LARGE(rs, rs->rs_size);
2773 void gss_svc_free_ctx(struct ptlrpc_svc_ctx *ctx)
2775 LASSERT(cfs_atomic_read(&ctx->sc_refcount) == 0);
2776 gss_svc_reqctx_free(gss_svc_ctx2reqctx(ctx));
2779 int gss_copy_rvc_cli_ctx(struct ptlrpc_cli_ctx *cli_ctx,
2780 struct ptlrpc_svc_ctx *svc_ctx)
2782 struct gss_cli_ctx *cli_gctx = ctx2gctx(cli_ctx);
2783 struct gss_svc_ctx *svc_gctx = gss_svc_ctx2gssctx(svc_ctx);
2784 struct gss_ctx *mechctx = NULL;
2787 LASSERT(svc_gctx && svc_gctx->gsc_mechctx);
2789 cli_gctx->gc_proc = PTLRPC_GSS_PROC_DATA;
2790 cli_gctx->gc_win = GSS_SEQ_WIN;
2792 /* The problem is the reverse ctx might get lost in some recovery
2793 * situations, and the same svc_ctx will be used to re-create it.
2794 * if there's callback be sentout before that, new reverse ctx start
2795 * with sequence 0 will lead to future callback rpc be treated as
2798 * each reverse root ctx will record its latest sequence number on its
2799 * buddy svcctx before be destroied, so here we continue use it.
2801 cfs_atomic_set(&cli_gctx->gc_seq, svc_gctx->gsc_rvs_seq);
2803 if (gss_svc_upcall_dup_handle(&cli_gctx->gc_svc_handle, svc_gctx)) {
2804 CERROR("failed to dup svc handle\n");
2808 if (lgss_copy_reverse_context(svc_gctx->gsc_mechctx, &mechctx) !=
2810 CERROR("failed to copy mech context\n");
2811 goto err_svc_handle;
2814 if (rawobj_dup(&cli_gctx->gc_handle, &svc_gctx->gsc_rvs_hdl)) {
2815 CERROR("failed to dup reverse handle\n");
2819 cli_gctx->gc_mechctx = mechctx;
2820 gss_cli_ctx_uptodate(cli_gctx);
2825 lgss_delete_sec_context(&mechctx);
2827 rawobj_free(&cli_gctx->gc_svc_handle);
2832 static void gss_init_at_reply_offset(void)
2837 buflens[0] = PTLRPC_GSS_HEADER_SIZE;
2838 buflens[1] = lustre_msg_early_size();
2839 buflens[2] = gss_cli_payload(NULL, buflens[1], 0);
2840 gss_at_reply_off_integ = lustre_msg_size_v2(3, buflens);
2842 buflens[0] = lustre_msg_early_size();
2843 clearsize = lustre_msg_size_v2(1, buflens);
2844 buflens[0] = PTLRPC_GSS_HEADER_SIZE;
2845 buflens[1] = gss_cli_payload(NULL, clearsize, 0);
2846 buflens[2] = gss_cli_payload(NULL, clearsize, 1);
2847 gss_at_reply_off_priv = lustre_msg_size_v2(3, buflens);
2850 int __init sptlrpc_gss_init(void)
2854 rc = gss_init_lproc();
2858 rc = gss_init_cli_upcall();
2862 rc = gss_init_svc_upcall();
2864 goto out_cli_upcall;
2866 rc = init_kerberos_module();
2868 goto out_svc_upcall;
2870 /* register policy after all other stuff be intialized, because it
2871 * might be in used immediately after the registration. */
2873 rc = gss_init_keyring();
2877 #ifdef HAVE_GSS_PIPEFS
2878 rc = gss_init_pipefs();
2883 gss_init_at_reply_offset();
2887 #ifdef HAVE_GSS_PIPEFS
2893 cleanup_kerberos_module();
2895 gss_exit_svc_upcall();
2897 gss_exit_cli_upcall();
2903 static void __exit sptlrpc_gss_exit(void)
2906 #ifdef HAVE_GSS_PIPEFS
2909 cleanup_kerberos_module();
2910 gss_exit_svc_upcall();
2911 gss_exit_cli_upcall();
2915 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
2916 MODULE_DESCRIPTION("GSS security policy for Lustre");
2917 MODULE_LICENSE("GPL");
2919 module_init(sptlrpc_gss_init);
2920 module_exit(sptlrpc_gss_exit);