aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/auth_gss
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2006-09-27 01:28:46 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-09-28 21:01:20 -0400
commit7699431301b189fca7ccbb64fe54e5a5170f8497 (patch)
tree4c20c5121776984cb054de3e0759cbeae860de3a /net/sunrpc/auth_gss
parent13d8eaa06abfeb708b60fa64203a20db033088b3 (diff)
[SUNRPC]: svc_{get,put}nl()
* add svc_getnl(): Take network-endian value from buffer, convert to host-endian and return it. * add svc_putnl(): Take host-endian value, convert to network-endian and put it into a buffer. * annotate svc_getu32()/svc_putu32() as dealing with network-endian. * convert to svc_getnl(), svc_putnl(). [AV: in large part it's a carved-up Alexey's patch] Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sunrpc/auth_gss')
-rw-r--r--net/sunrpc/auth_gss/svcauth_gss.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
index 94217ec9e2dd..cd3d77ca3a31 100644
--- a/net/sunrpc/auth_gss/svcauth_gss.c
+++ b/net/sunrpc/auth_gss/svcauth_gss.c
@@ -607,7 +607,7 @@ svc_safe_getnetobj(struct kvec *argv, struct xdr_netobj *o)
607 607
608 if (argv->iov_len < 4) 608 if (argv->iov_len < 4)
609 return -1; 609 return -1;
610 o->len = ntohl(svc_getu32(argv)); 610 o->len = svc_getnl(argv);
611 l = round_up_to_quad(o->len); 611 l = round_up_to_quad(o->len);
612 if (argv->iov_len < l) 612 if (argv->iov_len < l)
613 return -1; 613 return -1;
@@ -624,7 +624,7 @@ svc_safe_putnetobj(struct kvec *resv, struct xdr_netobj *o)
624 624
625 if (resv->iov_len + 4 > PAGE_SIZE) 625 if (resv->iov_len + 4 > PAGE_SIZE)
626 return -1; 626 return -1;
627 svc_putu32(resv, htonl(o->len)); 627 svc_putnl(resv, o->len);
628 p = resv->iov_base + resv->iov_len; 628 p = resv->iov_base + resv->iov_len;
629 resv->iov_len += round_up_to_quad(o->len); 629 resv->iov_len += round_up_to_quad(o->len);
630 if (resv->iov_len > PAGE_SIZE) 630 if (resv->iov_len > PAGE_SIZE)
@@ -657,7 +657,7 @@ gss_verify_header(struct svc_rqst *rqstp, struct rsc *rsci,
657 *authp = rpc_autherr_badverf; 657 *authp = rpc_autherr_badverf;
658 if (argv->iov_len < 4) 658 if (argv->iov_len < 4)
659 return SVC_DENIED; 659 return SVC_DENIED;
660 flavor = ntohl(svc_getu32(argv)); 660 flavor = svc_getnl(argv);
661 if (flavor != RPC_AUTH_GSS) 661 if (flavor != RPC_AUTH_GSS)
662 return SVC_DENIED; 662 return SVC_DENIED;
663 if (svc_safe_getnetobj(argv, &checksum)) 663 if (svc_safe_getnetobj(argv, &checksum))
@@ -689,7 +689,7 @@ gss_write_null_verf(struct svc_rqst *rqstp)
689{ 689{
690 u32 *p; 690 u32 *p;
691 691
692 svc_putu32(rqstp->rq_res.head, htonl(RPC_AUTH_NULL)); 692 svc_putnl(rqstp->rq_res.head, RPC_AUTH_NULL);
693 p = rqstp->rq_res.head->iov_base + rqstp->rq_res.head->iov_len; 693 p = rqstp->rq_res.head->iov_base + rqstp->rq_res.head->iov_len;
694 /* don't really need to check if head->iov_len > PAGE_SIZE ... */ 694 /* don't really need to check if head->iov_len > PAGE_SIZE ... */
695 *p++ = 0; 695 *p++ = 0;
@@ -708,7 +708,7 @@ gss_write_verf(struct svc_rqst *rqstp, struct gss_ctx *ctx_id, u32 seq)
708 u32 *p; 708 u32 *p;
709 struct kvec iov; 709 struct kvec iov;
710 710
711 svc_putu32(rqstp->rq_res.head, htonl(RPC_AUTH_GSS)); 711 svc_putnl(rqstp->rq_res.head, RPC_AUTH_GSS);
712 xdr_seq = htonl(seq); 712 xdr_seq = htonl(seq);
713 713
714 iov.iov_base = &xdr_seq; 714 iov.iov_base = &xdr_seq;
@@ -805,7 +805,7 @@ unwrap_integ_data(struct xdr_buf *buf, u32 seq, struct gss_ctx *ctx)
805 struct xdr_netobj mic; 805 struct xdr_netobj mic;
806 struct xdr_buf integ_buf; 806 struct xdr_buf integ_buf;
807 807
808 integ_len = ntohl(svc_getu32(&buf->head[0])); 808 integ_len = svc_getnl(&buf->head[0]);
809 if (integ_len & 3) 809 if (integ_len & 3)
810 goto out; 810 goto out;
811 if (integ_len > buf->len) 811 if (integ_len > buf->len)
@@ -825,7 +825,7 @@ unwrap_integ_data(struct xdr_buf *buf, u32 seq, struct gss_ctx *ctx)
825 maj_stat = gss_verify_mic(ctx, &integ_buf, &mic); 825 maj_stat = gss_verify_mic(ctx, &integ_buf, &mic);
826 if (maj_stat != GSS_S_COMPLETE) 826 if (maj_stat != GSS_S_COMPLETE)
827 goto out; 827 goto out;
828 if (ntohl(svc_getu32(&buf->head[0])) != seq) 828 if (svc_getnl(&buf->head[0]) != seq)
829 goto out; 829 goto out;
830 stat = 0; 830 stat = 0;
831out: 831out:
@@ -857,7 +857,7 @@ unwrap_priv_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct gs
857 857
858 rqstp->rq_sendfile_ok = 0; 858 rqstp->rq_sendfile_ok = 0;
859 859
860 priv_len = ntohl(svc_getu32(&buf->head[0])); 860 priv_len = svc_getnl(&buf->head[0]);
861 if (rqstp->rq_deferred) { 861 if (rqstp->rq_deferred) {
862 /* Already decrypted last time through! The sequence number 862 /* Already decrypted last time through! The sequence number
863 * check at out_seq is unnecessary but harmless: */ 863 * check at out_seq is unnecessary but harmless: */
@@ -895,7 +895,7 @@ unwrap_priv_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct gs
895 if (maj_stat != GSS_S_COMPLETE) 895 if (maj_stat != GSS_S_COMPLETE)
896 return -EINVAL; 896 return -EINVAL;
897out_seq: 897out_seq:
898 if (ntohl(svc_getu32(&buf->head[0])) != seq) 898 if (svc_getnl(&buf->head[0]) != seq)
899 return -EINVAL; 899 return -EINVAL;
900 return 0; 900 return 0;
901} 901}
@@ -985,12 +985,12 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
985 985
986 if (argv->iov_len < 5 * 4) 986 if (argv->iov_len < 5 * 4)
987 goto auth_err; 987 goto auth_err;
988 crlen = ntohl(svc_getu32(argv)); 988 crlen = svc_getnl(argv);
989 if (ntohl(svc_getu32(argv)) != RPC_GSS_VERSION) 989 if (svc_getnl(argv) != RPC_GSS_VERSION)
990 goto auth_err; 990 goto auth_err;
991 gc->gc_proc = ntohl(svc_getu32(argv)); 991 gc->gc_proc = svc_getnl(argv);
992 gc->gc_seq = ntohl(svc_getu32(argv)); 992 gc->gc_seq = svc_getnl(argv);
993 gc->gc_svc = ntohl(svc_getu32(argv)); 993 gc->gc_svc = svc_getnl(argv);
994 if (svc_safe_getnetobj(argv, &gc->gc_ctx)) 994 if (svc_safe_getnetobj(argv, &gc->gc_ctx))
995 goto auth_err; 995 goto auth_err;
996 if (crlen != round_up_to_quad(gc->gc_ctx.len) + 5 * 4) 996 if (crlen != round_up_to_quad(gc->gc_ctx.len) + 5 * 4)
@@ -1016,9 +1016,9 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
1016 case RPC_GSS_PROC_CONTINUE_INIT: 1016 case RPC_GSS_PROC_CONTINUE_INIT:
1017 if (argv->iov_len < 2 * 4) 1017 if (argv->iov_len < 2 * 4)
1018 goto auth_err; 1018 goto auth_err;
1019 if (ntohl(svc_getu32(argv)) != RPC_AUTH_NULL) 1019 if (svc_getnl(argv) != RPC_AUTH_NULL)
1020 goto auth_err; 1020 goto auth_err;
1021 if (ntohl(svc_getu32(argv)) != 0) 1021 if (svc_getnl(argv) != 0)
1022 goto auth_err; 1022 goto auth_err;
1023 break; 1023 break;
1024 case RPC_GSS_PROC_DATA: 1024 case RPC_GSS_PROC_DATA:
@@ -1076,14 +1076,14 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
1076 goto drop; 1076 goto drop;
1077 if (resv->iov_len + 4 > PAGE_SIZE) 1077 if (resv->iov_len + 4 > PAGE_SIZE)
1078 goto drop; 1078 goto drop;
1079 svc_putu32(resv, rpc_success); 1079 svc_putnl(resv, RPC_SUCCESS);
1080 if (svc_safe_putnetobj(resv, &rsip->out_handle)) 1080 if (svc_safe_putnetobj(resv, &rsip->out_handle))
1081 goto drop; 1081 goto drop;
1082 if (resv->iov_len + 3 * 4 > PAGE_SIZE) 1082 if (resv->iov_len + 3 * 4 > PAGE_SIZE)
1083 goto drop; 1083 goto drop;
1084 svc_putu32(resv, htonl(rsip->major_status)); 1084 svc_putnl(resv, rsip->major_status);
1085 svc_putu32(resv, htonl(rsip->minor_status)); 1085 svc_putnl(resv, rsip->minor_status);
1086 svc_putu32(resv, htonl(GSS_SEQ_WIN)); 1086 svc_putnl(resv, GSS_SEQ_WIN);
1087 if (svc_safe_putnetobj(resv, &rsip->out_token)) 1087 if (svc_safe_putnetobj(resv, &rsip->out_token))
1088 goto drop; 1088 goto drop;
1089 rqstp->rq_client = NULL; 1089 rqstp->rq_client = NULL;
@@ -1093,7 +1093,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
1093 set_bit(CACHE_NEGATIVE, &rsci->h.flags); 1093 set_bit(CACHE_NEGATIVE, &rsci->h.flags);
1094 if (resv->iov_len + 4 > PAGE_SIZE) 1094 if (resv->iov_len + 4 > PAGE_SIZE)
1095 goto drop; 1095 goto drop;
1096 svc_putu32(resv, rpc_success); 1096 svc_putnl(resv, RPC_SUCCESS);
1097 goto complete; 1097 goto complete;
1098 case RPC_GSS_PROC_DATA: 1098 case RPC_GSS_PROC_DATA:
1099 *authp = rpcsec_gsserr_ctxproblem; 1099 *authp = rpcsec_gsserr_ctxproblem;
@@ -1111,8 +1111,8 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
1111 goto auth_err; 1111 goto auth_err;
1112 /* placeholders for length and seq. number: */ 1112 /* placeholders for length and seq. number: */
1113 svcdata->body_start = resv->iov_base + resv->iov_len; 1113 svcdata->body_start = resv->iov_base + resv->iov_len;
1114 svc_putu32(resv, 0); 1114 svc_putnl(resv, 0);
1115 svc_putu32(resv, 0); 1115 svc_putnl(resv, 0);
1116 break; 1116 break;
1117 case RPC_GSS_SVC_PRIVACY: 1117 case RPC_GSS_SVC_PRIVACY:
1118 if (unwrap_priv_data(rqstp, &rqstp->rq_arg, 1118 if (unwrap_priv_data(rqstp, &rqstp->rq_arg,
@@ -1120,8 +1120,8 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
1120 goto auth_err; 1120 goto auth_err;
1121 /* placeholders for length and seq. number: */ 1121 /* placeholders for length and seq. number: */
1122 svcdata->body_start = resv->iov_base + resv->iov_len; 1122 svcdata->body_start = resv->iov_base + resv->iov_len;
1123 svc_putu32(resv, 0); 1123 svc_putnl(resv, 0);
1124 svc_putu32(resv, 0); 1124 svc_putnl(resv, 0);
1125 break; 1125 break;
1126 default: 1126 default:
1127 goto auth_err; 1127 goto auth_err;
@@ -1199,7 +1199,7 @@ svcauth_gss_wrap_resp_integ(struct svc_rqst *rqstp)
1199 mic.data = (u8 *)resv->iov_base + resv->iov_len + 4; 1199 mic.data = (u8 *)resv->iov_base + resv->iov_len + 4;
1200 if (gss_get_mic(gsd->rsci->mechctx, &integ_buf, &mic)) 1200 if (gss_get_mic(gsd->rsci->mechctx, &integ_buf, &mic))
1201 goto out_err; 1201 goto out_err;
1202 svc_putu32(resv, htonl(mic.len)); 1202 svc_putnl(resv, mic.len);
1203 memset(mic.data + mic.len, 0, 1203 memset(mic.data + mic.len, 0,
1204 round_up_to_quad(mic.len) - mic.len); 1204 round_up_to_quad(mic.len) - mic.len);
1205 resv->iov_len += XDR_QUADLEN(mic.len) << 2; 1205 resv->iov_len += XDR_QUADLEN(mic.len) << 2;