Lines Matching refs:gss_msg

299 gss_release_msg(struct gss_upcall_msg *gss_msg)  in gss_release_msg()  argument
301 struct net *net = gss_msg->auth->net; in gss_release_msg()
302 if (!refcount_dec_and_test(&gss_msg->count)) in gss_release_msg()
305 BUG_ON(!list_empty(&gss_msg->list)); in gss_release_msg()
306 if (gss_msg->ctx != NULL) in gss_release_msg()
307 gss_put_ctx(gss_msg->ctx); in gss_release_msg()
308 rpc_destroy_wait_queue(&gss_msg->rpc_waitqueue); in gss_release_msg()
309 gss_put_auth(gss_msg->auth); in gss_release_msg()
310 kfree_const(gss_msg->service_name); in gss_release_msg()
311 kfree(gss_msg); in gss_release_msg()
334 gss_add_msg(struct gss_upcall_msg *gss_msg) in gss_add_msg() argument
336 struct rpc_pipe *pipe = gss_msg->pipe; in gss_add_msg()
340 old = __gss_find_upcall(pipe, gss_msg->uid, gss_msg->auth); in gss_add_msg()
342 refcount_inc(&gss_msg->count); in gss_add_msg()
343 list_add(&gss_msg->list, &pipe->in_downcall); in gss_add_msg()
345 gss_msg = old; in gss_add_msg()
347 return gss_msg; in gss_add_msg()
351 __gss_unhash_msg(struct gss_upcall_msg *gss_msg) in __gss_unhash_msg() argument
353 list_del_init(&gss_msg->list); in __gss_unhash_msg()
354 rpc_wake_up_status(&gss_msg->rpc_waitqueue, gss_msg->msg.errno); in __gss_unhash_msg()
355 wake_up_all(&gss_msg->waitqueue); in __gss_unhash_msg()
356 refcount_dec(&gss_msg->count); in __gss_unhash_msg()
360 gss_unhash_msg(struct gss_upcall_msg *gss_msg) in gss_unhash_msg() argument
362 struct rpc_pipe *pipe = gss_msg->pipe; in gss_unhash_msg()
364 if (list_empty(&gss_msg->list)) in gss_unhash_msg()
367 if (!list_empty(&gss_msg->list)) in gss_unhash_msg()
368 __gss_unhash_msg(gss_msg); in gss_unhash_msg()
373 gss_handle_downcall_result(struct gss_cred *gss_cred, struct gss_upcall_msg *gss_msg) in gss_handle_downcall_result() argument
375 switch (gss_msg->msg.errno) { in gss_handle_downcall_result()
377 if (gss_msg->ctx == NULL) in gss_handle_downcall_result()
380 gss_cred_set_ctx(&gss_cred->gc_base, gss_msg->ctx); in gss_handle_downcall_result()
387 rpc_wake_up_status(&gss_msg->rpc_waitqueue, gss_msg->msg.errno); in gss_handle_downcall_result()
395 struct gss_upcall_msg *gss_msg = gss_cred->gc_upcall; in gss_upcall_callback() local
396 struct rpc_pipe *pipe = gss_msg->pipe; in gss_upcall_callback()
399 gss_handle_downcall_result(gss_cred, gss_msg); in gss_upcall_callback()
401 task->tk_status = gss_msg->msg.errno; in gss_upcall_callback()
402 gss_release_msg(gss_msg); in gss_upcall_callback()
405 static void gss_encode_v0_msg(struct gss_upcall_msg *gss_msg, in gss_encode_v0_msg() argument
410 uid_t uid = from_kuid_munged(userns, gss_msg->uid); in gss_encode_v0_msg()
411 memcpy(gss_msg->databuf, &uid, sizeof(uid)); in gss_encode_v0_msg()
412 gss_msg->msg.data = gss_msg->databuf; in gss_encode_v0_msg()
413 gss_msg->msg.len = sizeof(uid); in gss_encode_v0_msg()
415 BUILD_BUG_ON(sizeof(uid) > sizeof(gss_msg->databuf)); in gss_encode_v0_msg()
422 struct gss_upcall_msg *gss_msg = container_of(msg, in gss_v0_upcall() local
426 gss_encode_v0_msg(gss_msg, file->f_cred); in gss_v0_upcall()
430 static int gss_encode_v1_msg(struct gss_upcall_msg *gss_msg, in gss_encode_v1_msg() argument
436 struct gss_api_mech *mech = gss_msg->auth->mech; in gss_encode_v1_msg()
437 char *p = gss_msg->databuf; in gss_encode_v1_msg()
438 size_t buflen = sizeof(gss_msg->databuf); in gss_encode_v1_msg()
442 from_kuid_munged(userns, gss_msg->uid)); in gss_encode_v1_msg()
445 gss_msg->msg.len = len; in gss_encode_v1_msg()
455 gss_msg->msg.len += len; in gss_encode_v1_msg()
481 gss_msg->msg.len += len; in gss_encode_v1_msg()
489 gss_msg->msg.len += len; in gss_encode_v1_msg()
491 trace_rpcgss_upcall_msg(gss_msg->databuf); in gss_encode_v1_msg()
495 gss_msg->msg.len += len; in gss_encode_v1_msg()
496 gss_msg->msg.data = gss_msg->databuf; in gss_encode_v1_msg()
507 struct gss_upcall_msg *gss_msg = container_of(msg, in gss_v1_upcall() local
512 err = gss_encode_v1_msg(gss_msg, in gss_v1_upcall()
513 gss_msg->service_name, in gss_v1_upcall()
514 gss_msg->auth->target_name, in gss_v1_upcall()
526 struct gss_upcall_msg *gss_msg; in gss_alloc_msg() local
530 gss_msg = kzalloc(sizeof(*gss_msg), GFP_KERNEL); in gss_alloc_msg()
531 if (gss_msg == NULL) in gss_alloc_msg()
537 gss_msg->pipe = gss_auth->gss_pipe[vers]->pipe; in gss_alloc_msg()
538 INIT_LIST_HEAD(&gss_msg->list); in gss_alloc_msg()
539 rpc_init_wait_queue(&gss_msg->rpc_waitqueue, "RPCSEC_GSS upcall waitq"); in gss_alloc_msg()
540 init_waitqueue_head(&gss_msg->waitqueue); in gss_alloc_msg()
541 refcount_set(&gss_msg->count, 1); in gss_alloc_msg()
542 gss_msg->uid = uid; in gss_alloc_msg()
543 gss_msg->auth = gss_auth; in gss_alloc_msg()
546 gss_msg->service_name = kstrdup_const(service_name, GFP_KERNEL); in gss_alloc_msg()
547 if (!gss_msg->service_name) { in gss_alloc_msg()
552 return gss_msg; in gss_alloc_msg()
556 kfree(gss_msg); in gss_alloc_msg()
566 struct gss_upcall_msg *gss_new, *gss_msg; in gss_setup_upcall() local
572 gss_msg = gss_add_msg(gss_new); in gss_setup_upcall()
573 if (gss_msg == gss_new) { in gss_setup_upcall()
575 refcount_inc(&gss_msg->count); in gss_setup_upcall()
579 refcount_dec(&gss_msg->count); in gss_setup_upcall()
581 gss_msg = ERR_PTR(res); in gss_setup_upcall()
585 return gss_msg; in gss_setup_upcall()
601 struct gss_upcall_msg *gss_msg; in gss_refresh_upcall() local
605 gss_msg = gss_setup_upcall(gss_auth, cred); in gss_refresh_upcall()
606 if (PTR_ERR(gss_msg) == -EAGAIN) { in gss_refresh_upcall()
615 if (IS_ERR(gss_msg)) { in gss_refresh_upcall()
616 err = PTR_ERR(gss_msg); in gss_refresh_upcall()
619 pipe = gss_msg->pipe; in gss_refresh_upcall()
623 else if (gss_msg->ctx == NULL && gss_msg->msg.errno >= 0) { in gss_refresh_upcall()
624 gss_cred->gc_upcall = gss_msg; in gss_refresh_upcall()
626 refcount_inc(&gss_msg->count); in gss_refresh_upcall()
627 rpc_sleep_on(&gss_msg->rpc_waitqueue, task, gss_upcall_callback); in gss_refresh_upcall()
629 gss_handle_downcall_result(gss_cred, gss_msg); in gss_refresh_upcall()
630 err = gss_msg->msg.errno; in gss_refresh_upcall()
633 gss_release_msg(gss_msg); in gss_refresh_upcall()
647 struct gss_upcall_msg *gss_msg; in gss_create_upcall() local
659 gss_msg = gss_setup_upcall(gss_auth, cred); in gss_create_upcall()
660 if (PTR_ERR(gss_msg) == -EAGAIN) { in gss_create_upcall()
671 if (IS_ERR(gss_msg)) { in gss_create_upcall()
672 err = PTR_ERR(gss_msg); in gss_create_upcall()
675 pipe = gss_msg->pipe; in gss_create_upcall()
677 prepare_to_wait(&gss_msg->waitqueue, &wait, TASK_KILLABLE); in gss_create_upcall()
679 if (gss_msg->ctx != NULL || gss_msg->msg.errno < 0) { in gss_create_upcall()
689 if (gss_msg->ctx) { in gss_create_upcall()
691 gss_cred_set_ctx(cred, gss_msg->ctx); in gss_create_upcall()
693 err = gss_msg->msg.errno; in gss_create_upcall()
697 finish_wait(&gss_msg->waitqueue, &wait); in gss_create_upcall()
698 gss_release_msg(gss_msg); in gss_create_upcall()
727 struct gss_upcall_msg *gss_msg; in gss_pipe_downcall() local
766 gss_msg = gss_find_downcall(pipe, uid); in gss_pipe_downcall()
767 if (gss_msg == NULL) { in gss_pipe_downcall()
771 list_del_init(&gss_msg->list); in gss_pipe_downcall()
774 p = gss_fill_context(p, end, ctx, gss_msg->auth->mech); in gss_pipe_downcall()
780 gss_msg->msg.errno = err; in gss_pipe_downcall()
787 gss_msg->msg.errno = -EAGAIN; in gss_pipe_downcall()
792 gss_msg->msg.errno = -EIO; in gss_pipe_downcall()
796 gss_msg->ctx = gss_get_ctx(ctx); in gss_pipe_downcall()
801 __gss_unhash_msg(gss_msg); in gss_pipe_downcall()
803 gss_release_msg(gss_msg); in gss_pipe_downcall()
851 struct gss_upcall_msg *gss_msg; in gss_pipe_release() local
855 list_for_each_entry(gss_msg, &pipe->in_downcall, list) { in gss_pipe_release()
857 if (!list_empty(&gss_msg->msg.list)) in gss_pipe_release()
859 gss_msg->msg.errno = -EPIPE; in gss_pipe_release()
860 refcount_inc(&gss_msg->count); in gss_pipe_release()
861 __gss_unhash_msg(gss_msg); in gss_pipe_release()
863 gss_release_msg(gss_msg); in gss_pipe_release()
874 struct gss_upcall_msg *gss_msg = container_of(msg, struct gss_upcall_msg, msg); in gss_pipe_destroy_msg() local
877 refcount_inc(&gss_msg->count); in gss_pipe_destroy_msg()
878 gss_unhash_msg(gss_msg); in gss_pipe_destroy_msg()
881 gss_release_msg(gss_msg); in gss_pipe_destroy_msg()
883 gss_release_msg(gss_msg); in gss_pipe_destroy_msg()