Commit 76994313 authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by David S. Miller

[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: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 13d8eaa0
...@@ -78,28 +78,45 @@ struct svc_serv { ...@@ -78,28 +78,45 @@ struct svc_serv {
*/ */
#define RPCSVC_MAXPAGES ((RPCSVC_MAXPAYLOAD+PAGE_SIZE-1)/PAGE_SIZE + 2) #define RPCSVC_MAXPAGES ((RPCSVC_MAXPAYLOAD+PAGE_SIZE-1)/PAGE_SIZE + 2)
static inline u32 svc_getu32(struct kvec *iov) static inline u32 svc_getnl(struct kvec *iov)
{ {
u32 val, *vp; __be32 val, *vp;
vp = iov->iov_base; vp = iov->iov_base;
val = *vp++; val = *vp++;
iov->iov_base = (void*)vp; iov->iov_base = (void*)vp;
iov->iov_len -= sizeof(u32); iov->iov_len -= sizeof(__be32);
return ntohl(val);
}
static inline void svc_putnl(struct kvec *iov, u32 val)
{
__be32 *vp = iov->iov_base + iov->iov_len;
*vp = htonl(val);
iov->iov_len += sizeof(__be32);
}
static inline __be32 svc_getu32(struct kvec *iov)
{
__be32 val, *vp;
vp = iov->iov_base;
val = *vp++;
iov->iov_base = (void*)vp;
iov->iov_len -= sizeof(__be32);
return val; return val;
} }
static inline void svc_ungetu32(struct kvec *iov) static inline void svc_ungetu32(struct kvec *iov)
{ {
u32 *vp = (u32 *)iov->iov_base; __be32 *vp = (__be32 *)iov->iov_base;
iov->iov_base = (void *)(vp - 1); iov->iov_base = (void *)(vp - 1);
iov->iov_len += sizeof(*vp); iov->iov_len += sizeof(*vp);
} }
static inline void svc_putu32(struct kvec *iov, u32 val) static inline void svc_putu32(struct kvec *iov, __be32 val)
{ {
u32 *vp = iov->iov_base + iov->iov_len; __be32 *vp = iov->iov_base + iov->iov_len;
*vp = val; *vp = val;
iov->iov_len += sizeof(u32); iov->iov_len += sizeof(__be32);
} }
......
...@@ -607,7 +607,7 @@ svc_safe_getnetobj(struct kvec *argv, struct xdr_netobj *o) ...@@ -607,7 +607,7 @@ svc_safe_getnetobj(struct kvec *argv, struct xdr_netobj *o)
if (argv->iov_len < 4) if (argv->iov_len < 4)
return -1; return -1;
o->len = ntohl(svc_getu32(argv)); o->len = svc_getnl(argv);
l = round_up_to_quad(o->len); l = round_up_to_quad(o->len);
if (argv->iov_len < l) if (argv->iov_len < l)
return -1; return -1;
...@@ -624,7 +624,7 @@ svc_safe_putnetobj(struct kvec *resv, struct xdr_netobj *o) ...@@ -624,7 +624,7 @@ svc_safe_putnetobj(struct kvec *resv, struct xdr_netobj *o)
if (resv->iov_len + 4 > PAGE_SIZE) if (resv->iov_len + 4 > PAGE_SIZE)
return -1; return -1;
svc_putu32(resv, htonl(o->len)); svc_putnl(resv, o->len);
p = resv->iov_base + resv->iov_len; p = resv->iov_base + resv->iov_len;
resv->iov_len += round_up_to_quad(o->len); resv->iov_len += round_up_to_quad(o->len);
if (resv->iov_len > PAGE_SIZE) if (resv->iov_len > PAGE_SIZE)
...@@ -657,7 +657,7 @@ gss_verify_header(struct svc_rqst *rqstp, struct rsc *rsci, ...@@ -657,7 +657,7 @@ gss_verify_header(struct svc_rqst *rqstp, struct rsc *rsci,
*authp = rpc_autherr_badverf; *authp = rpc_autherr_badverf;
if (argv->iov_len < 4) if (argv->iov_len < 4)
return SVC_DENIED; return SVC_DENIED;
flavor = ntohl(svc_getu32(argv)); flavor = svc_getnl(argv);
if (flavor != RPC_AUTH_GSS) if (flavor != RPC_AUTH_GSS)
return SVC_DENIED; return SVC_DENIED;
if (svc_safe_getnetobj(argv, &checksum)) if (svc_safe_getnetobj(argv, &checksum))
...@@ -689,7 +689,7 @@ gss_write_null_verf(struct svc_rqst *rqstp) ...@@ -689,7 +689,7 @@ gss_write_null_verf(struct svc_rqst *rqstp)
{ {
u32 *p; u32 *p;
svc_putu32(rqstp->rq_res.head, htonl(RPC_AUTH_NULL)); svc_putnl(rqstp->rq_res.head, RPC_AUTH_NULL);
p = rqstp->rq_res.head->iov_base + rqstp->rq_res.head->iov_len; p = rqstp->rq_res.head->iov_base + rqstp->rq_res.head->iov_len;
/* don't really need to check if head->iov_len > PAGE_SIZE ... */ /* don't really need to check if head->iov_len > PAGE_SIZE ... */
*p++ = 0; *p++ = 0;
...@@ -708,7 +708,7 @@ gss_write_verf(struct svc_rqst *rqstp, struct gss_ctx *ctx_id, u32 seq) ...@@ -708,7 +708,7 @@ gss_write_verf(struct svc_rqst *rqstp, struct gss_ctx *ctx_id, u32 seq)
u32 *p; u32 *p;
struct kvec iov; struct kvec iov;
svc_putu32(rqstp->rq_res.head, htonl(RPC_AUTH_GSS)); svc_putnl(rqstp->rq_res.head, RPC_AUTH_GSS);
xdr_seq = htonl(seq); xdr_seq = htonl(seq);
iov.iov_base = &xdr_seq; iov.iov_base = &xdr_seq;
...@@ -805,7 +805,7 @@ unwrap_integ_data(struct xdr_buf *buf, u32 seq, struct gss_ctx *ctx) ...@@ -805,7 +805,7 @@ unwrap_integ_data(struct xdr_buf *buf, u32 seq, struct gss_ctx *ctx)
struct xdr_netobj mic; struct xdr_netobj mic;
struct xdr_buf integ_buf; struct xdr_buf integ_buf;
integ_len = ntohl(svc_getu32(&buf->head[0])); integ_len = svc_getnl(&buf->head[0]);
if (integ_len & 3) if (integ_len & 3)
goto out; goto out;
if (integ_len > buf->len) if (integ_len > buf->len)
...@@ -825,7 +825,7 @@ unwrap_integ_data(struct xdr_buf *buf, u32 seq, struct gss_ctx *ctx) ...@@ -825,7 +825,7 @@ unwrap_integ_data(struct xdr_buf *buf, u32 seq, struct gss_ctx *ctx)
maj_stat = gss_verify_mic(ctx, &integ_buf, &mic); maj_stat = gss_verify_mic(ctx, &integ_buf, &mic);
if (maj_stat != GSS_S_COMPLETE) if (maj_stat != GSS_S_COMPLETE)
goto out; goto out;
if (ntohl(svc_getu32(&buf->head[0])) != seq) if (svc_getnl(&buf->head[0]) != seq)
goto out; goto out;
stat = 0; stat = 0;
out: out:
...@@ -857,7 +857,7 @@ unwrap_priv_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct gs ...@@ -857,7 +857,7 @@ unwrap_priv_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct gs
rqstp->rq_sendfile_ok = 0; rqstp->rq_sendfile_ok = 0;
priv_len = ntohl(svc_getu32(&buf->head[0])); priv_len = svc_getnl(&buf->head[0]);
if (rqstp->rq_deferred) { if (rqstp->rq_deferred) {
/* Already decrypted last time through! The sequence number /* Already decrypted last time through! The sequence number
* check at out_seq is unnecessary but harmless: */ * 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,7 +895,7 @@ unwrap_priv_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct gs
if (maj_stat != GSS_S_COMPLETE) if (maj_stat != GSS_S_COMPLETE)
return -EINVAL; return -EINVAL;
out_seq: out_seq:
if (ntohl(svc_getu32(&buf->head[0])) != seq) if (svc_getnl(&buf->head[0]) != seq)
return -EINVAL; return -EINVAL;
return 0; return 0;
} }
...@@ -985,12 +985,12 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp) ...@@ -985,12 +985,12 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
if (argv->iov_len < 5 * 4) if (argv->iov_len < 5 * 4)
goto auth_err; goto auth_err;
crlen = ntohl(svc_getu32(argv)); crlen = svc_getnl(argv);
if (ntohl(svc_getu32(argv)) != RPC_GSS_VERSION) if (svc_getnl(argv) != RPC_GSS_VERSION)
goto auth_err; goto auth_err;
gc->gc_proc = ntohl(svc_getu32(argv)); gc->gc_proc = svc_getnl(argv);
gc->gc_seq = ntohl(svc_getu32(argv)); gc->gc_seq = svc_getnl(argv);
gc->gc_svc = ntohl(svc_getu32(argv)); gc->gc_svc = svc_getnl(argv);
if (svc_safe_getnetobj(argv, &gc->gc_ctx)) if (svc_safe_getnetobj(argv, &gc->gc_ctx))
goto auth_err; goto auth_err;
if (crlen != round_up_to_quad(gc->gc_ctx.len) + 5 * 4) 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,9 +1016,9 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
case RPC_GSS_PROC_CONTINUE_INIT: case RPC_GSS_PROC_CONTINUE_INIT:
if (argv->iov_len < 2 * 4) if (argv->iov_len < 2 * 4)
goto auth_err; goto auth_err;
if (ntohl(svc_getu32(argv)) != RPC_AUTH_NULL) if (svc_getnl(argv) != RPC_AUTH_NULL)
goto auth_err; goto auth_err;
if (ntohl(svc_getu32(argv)) != 0) if (svc_getnl(argv) != 0)
goto auth_err; goto auth_err;
break; break;
case RPC_GSS_PROC_DATA: case RPC_GSS_PROC_DATA:
...@@ -1076,14 +1076,14 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp) ...@@ -1076,14 +1076,14 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
goto drop; goto drop;
if (resv->iov_len + 4 > PAGE_SIZE) if (resv->iov_len + 4 > PAGE_SIZE)
goto drop; goto drop;
svc_putu32(resv, rpc_success); svc_putnl(resv, RPC_SUCCESS);
if (svc_safe_putnetobj(resv, &rsip->out_handle)) if (svc_safe_putnetobj(resv, &rsip->out_handle))
goto drop; goto drop;
if (resv->iov_len + 3 * 4 > PAGE_SIZE) if (resv->iov_len + 3 * 4 > PAGE_SIZE)
goto drop; goto drop;
svc_putu32(resv, htonl(rsip->major_status)); svc_putnl(resv, rsip->major_status);
svc_putu32(resv, htonl(rsip->minor_status)); svc_putnl(resv, rsip->minor_status);
svc_putu32(resv, htonl(GSS_SEQ_WIN)); svc_putnl(resv, GSS_SEQ_WIN);
if (svc_safe_putnetobj(resv, &rsip->out_token)) if (svc_safe_putnetobj(resv, &rsip->out_token))
goto drop; goto drop;
rqstp->rq_client = NULL; rqstp->rq_client = NULL;
...@@ -1093,7 +1093,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp) ...@@ -1093,7 +1093,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
set_bit(CACHE_NEGATIVE, &rsci->h.flags); set_bit(CACHE_NEGATIVE, &rsci->h.flags);
if (resv->iov_len + 4 > PAGE_SIZE) if (resv->iov_len + 4 > PAGE_SIZE)
goto drop; goto drop;
svc_putu32(resv, rpc_success); svc_putnl(resv, RPC_SUCCESS);
goto complete; goto complete;
case RPC_GSS_PROC_DATA: case RPC_GSS_PROC_DATA:
*authp = rpcsec_gsserr_ctxproblem; *authp = rpcsec_gsserr_ctxproblem;
...@@ -1111,8 +1111,8 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp) ...@@ -1111,8 +1111,8 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
goto auth_err; goto auth_err;
/* placeholders for length and seq. number: */ /* placeholders for length and seq. number: */
svcdata->body_start = resv->iov_base + resv->iov_len; svcdata->body_start = resv->iov_base + resv->iov_len;
svc_putu32(resv, 0); svc_putnl(resv, 0);
svc_putu32(resv, 0); svc_putnl(resv, 0);
break; break;
case RPC_GSS_SVC_PRIVACY: case RPC_GSS_SVC_PRIVACY:
if (unwrap_priv_data(rqstp, &rqstp->rq_arg, if (unwrap_priv_data(rqstp, &rqstp->rq_arg,
...@@ -1120,8 +1120,8 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp) ...@@ -1120,8 +1120,8 @@ svcauth_gss_accept(struct svc_rqst *rqstp, u32 *authp)
goto auth_err; goto auth_err;
/* placeholders for length and seq. number: */ /* placeholders for length and seq. number: */
svcdata->body_start = resv->iov_base + resv->iov_len; svcdata->body_start = resv->iov_base + resv->iov_len;
svc_putu32(resv, 0); svc_putnl(resv, 0);
svc_putu32(resv, 0); svc_putnl(resv, 0);
break; break;
default: default:
goto auth_err; goto auth_err;
...@@ -1199,7 +1199,7 @@ svcauth_gss_wrap_resp_integ(struct svc_rqst *rqstp) ...@@ -1199,7 +1199,7 @@ svcauth_gss_wrap_resp_integ(struct svc_rqst *rqstp)
mic.data = (u8 *)resv->iov_base + resv->iov_len + 4; mic.data = (u8 *)resv->iov_base + resv->iov_len + 4;
if (gss_get_mic(gsd->rsci->mechctx, &integ_buf, &mic)) if (gss_get_mic(gsd->rsci->mechctx, &integ_buf, &mic))
goto out_err; goto out_err;
svc_putu32(resv, htonl(mic.len)); svc_putnl(resv, mic.len);
memset(mic.data + mic.len, 0, memset(mic.data + mic.len, 0,
round_up_to_quad(mic.len) - mic.len); round_up_to_quad(mic.len) - mic.len);
resv->iov_len += XDR_QUADLEN(mic.len) << 2; resv->iov_len += XDR_QUADLEN(mic.len) << 2;
......
...@@ -284,16 +284,16 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp) ...@@ -284,16 +284,16 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp)
rqstp->rq_sendfile_ok = 1; rqstp->rq_sendfile_ok = 1;
/* tcp needs a space for the record length... */ /* tcp needs a space for the record length... */
if (rqstp->rq_prot == IPPROTO_TCP) if (rqstp->rq_prot == IPPROTO_TCP)
svc_putu32(resv, 0); svc_putnl(resv, 0);
rqstp->rq_xid = svc_getu32(argv); rqstp->rq_xid = svc_getu32(argv);
svc_putu32(resv, rqstp->rq_xid); svc_putu32(resv, rqstp->rq_xid);
dir = ntohl(svc_getu32(argv)); dir = svc_getnl(argv);
vers = ntohl(svc_getu32(argv)); vers = svc_getnl(argv);
/* First words of reply: */ /* First words of reply: */
svc_putu32(resv, xdr_one); /* REPLY */ svc_putnl(resv, 1); /* REPLY */
if (dir != 0) /* direction != CALL */ if (dir != 0) /* direction != CALL */
goto err_bad_dir; goto err_bad_dir;
...@@ -303,11 +303,11 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp) ...@@ -303,11 +303,11 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp)
/* Save position in case we later decide to reject: */ /* Save position in case we later decide to reject: */
accept_statp = resv->iov_base + resv->iov_len; accept_statp = resv->iov_base + resv->iov_len;
svc_putu32(resv, xdr_zero); /* ACCEPT */ svc_putnl(resv, 0); /* ACCEPT */
rqstp->rq_prog = prog = ntohl(svc_getu32(argv)); /* program number */ rqstp->rq_prog = prog = svc_getnl(argv); /* program number */
rqstp->rq_vers = vers = ntohl(svc_getu32(argv)); /* version number */ rqstp->rq_vers = vers = svc_getnl(argv); /* version number */
rqstp->rq_proc = proc = ntohl(svc_getu32(argv)); /* procedure number */ rqstp->rq_proc = proc = svc_getnl(argv); /* procedure number */
progp = serv->sv_program; progp = serv->sv_program;
...@@ -361,7 +361,7 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp) ...@@ -361,7 +361,7 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp)
/* Build the reply header. */ /* Build the reply header. */
statp = resv->iov_base +resv->iov_len; statp = resv->iov_base +resv->iov_len;
svc_putu32(resv, rpc_success); /* RPC_SUCCESS */ svc_putnl(resv, RPC_SUCCESS);
/* Bump per-procedure stats counter */ /* Bump per-procedure stats counter */
procp->pc_count++; procp->pc_count++;
...@@ -439,10 +439,10 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp) ...@@ -439,10 +439,10 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp)
err_bad_rpc: err_bad_rpc:
serv->sv_stats->rpcbadfmt++; serv->sv_stats->rpcbadfmt++;
svc_putu32(resv, xdr_one); /* REJECT */ svc_putnl(resv, 1); /* REJECT */
svc_putu32(resv, xdr_zero); /* RPC_MISMATCH */ svc_putnl(resv, 0); /* RPC_MISMATCH */
svc_putu32(resv, xdr_two); /* Only RPCv2 supported */ svc_putnl(resv, 2); /* Only RPCv2 supported */
svc_putu32(resv, xdr_two); svc_putnl(resv, 2);
goto sendit; goto sendit;
err_bad_auth: err_bad_auth:
...@@ -450,15 +450,15 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp) ...@@ -450,15 +450,15 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp)
serv->sv_stats->rpcbadauth++; serv->sv_stats->rpcbadauth++;
/* Restore write pointer to location of accept status: */ /* Restore write pointer to location of accept status: */
xdr_ressize_check(rqstp, accept_statp); xdr_ressize_check(rqstp, accept_statp);
svc_putu32(resv, xdr_one); /* REJECT */ svc_putnl(resv, 1); /* REJECT */
svc_putu32(resv, xdr_one); /* AUTH_ERROR */ svc_putnl(resv, 1); /* AUTH_ERROR */
svc_putu32(resv, auth_stat); /* status */ svc_putnl(resv, ntohl(auth_stat)); /* status */
goto sendit; goto sendit;
err_bad_prog: err_bad_prog:
dprintk("svc: unknown program %d\n", prog); dprintk("svc: unknown program %d\n", prog);
serv->sv_stats->rpcbadfmt++; serv->sv_stats->rpcbadfmt++;
svc_putu32(resv, rpc_prog_unavail); svc_putnl(resv, RPC_PROG_UNAVAIL);
goto sendit; goto sendit;
err_bad_vers: err_bad_vers:
...@@ -466,9 +466,9 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp) ...@@ -466,9 +466,9 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp)
printk("svc: unknown version (%d)\n", vers); printk("svc: unknown version (%d)\n", vers);
#endif #endif
serv->sv_stats->rpcbadfmt++; serv->sv_stats->rpcbadfmt++;
svc_putu32(resv, rpc_prog_mismatch); svc_putnl(resv, RPC_PROG_MISMATCH);
svc_putu32(resv, htonl(progp->pg_lovers)); svc_putnl(resv, progp->pg_lovers);
svc_putu32(resv, htonl(progp->pg_hivers)); svc_putnl(resv, progp->pg_hivers);
goto sendit; goto sendit;
err_bad_proc: err_bad_proc:
...@@ -476,7 +476,7 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp) ...@@ -476,7 +476,7 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp)
printk("svc: unknown procedure (%d)\n", proc); printk("svc: unknown procedure (%d)\n", proc);
#endif #endif
serv->sv_stats->rpcbadfmt++; serv->sv_stats->rpcbadfmt++;
svc_putu32(resv, rpc_proc_unavail); svc_putnl(resv, RPC_PROC_UNAVAIL);
goto sendit; goto sendit;
err_garbage: err_garbage:
...@@ -486,6 +486,6 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp) ...@@ -486,6 +486,6 @@ svc_process(struct svc_serv *serv, struct svc_rqst *rqstp)
rpc_stat = rpc_garbage_args; rpc_stat = rpc_garbage_args;
err_bad: err_bad:
serv->sv_stats->rpcbadfmt++; serv->sv_stats->rpcbadfmt++;
svc_putu32(resv, rpc_stat); svc_putnl(resv, ntohl(rpc_stat));
goto sendit; goto sendit;
} }
...@@ -42,7 +42,7 @@ svc_authenticate(struct svc_rqst *rqstp, u32 *authp) ...@@ -42,7 +42,7 @@ svc_authenticate(struct svc_rqst *rqstp, u32 *authp)
*authp = rpc_auth_ok; *authp = rpc_auth_ok;
flavor = ntohl(svc_getu32(&rqstp->rq_arg.head[0])); flavor = svc_getnl(&rqstp->rq_arg.head[0]);
dprintk("svc: svc_authenticate (%d)\n", flavor); dprintk("svc: svc_authenticate (%d)\n", flavor);
......
...@@ -427,7 +427,7 @@ svcauth_null_accept(struct svc_rqst *rqstp, u32 *authp) ...@@ -427,7 +427,7 @@ svcauth_null_accept(struct svc_rqst *rqstp, u32 *authp)
*authp = rpc_autherr_badcred; *authp = rpc_autherr_badcred;
return SVC_DENIED; return SVC_DENIED;
} }
if (svc_getu32(argv) != RPC_AUTH_NULL || svc_getu32(argv) != 0) { if (svc_getu32(argv) != htonl(RPC_AUTH_NULL) || svc_getu32(argv) != 0) {
dprintk("svc: bad null verf\n"); dprintk("svc: bad null verf\n");
*authp = rpc_autherr_badverf; *authp = rpc_autherr_badverf;
return SVC_DENIED; return SVC_DENIED;
...@@ -441,8 +441,8 @@ svcauth_null_accept(struct svc_rqst *rqstp, u32 *authp) ...@@ -441,8 +441,8 @@ svcauth_null_accept(struct svc_rqst *rqstp, u32 *authp)
return SVC_DROP; /* kmalloc failure - client must retry */ return SVC_DROP; /* kmalloc failure - client must retry */
/* Put NULL verifier */ /* Put NULL verifier */
svc_putu32(resv, RPC_AUTH_NULL); svc_putnl(resv, RPC_AUTH_NULL);
svc_putu32(resv, 0); svc_putnl(resv, 0);
return SVC_OK; return SVC_OK;
} }
...@@ -488,31 +488,31 @@ svcauth_unix_accept(struct svc_rqst *rqstp, u32 *authp) ...@@ -488,31 +488,31 @@ svcauth_unix_accept(struct svc_rqst *rqstp, u32 *authp)
svc_getu32(argv); /* length */ svc_getu32(argv); /* length */
svc_getu32(argv); /* time stamp */ svc_getu32(argv); /* time stamp */
slen = XDR_QUADLEN(ntohl(svc_getu32(argv))); /* machname length */ slen = XDR_QUADLEN(svc_getnl(argv)); /* machname length */
if (slen > 64 || (len -= (slen + 3)*4) < 0) if (slen > 64 || (len -= (slen + 3)*4) < 0)
goto badcred; goto badcred;
argv->iov_base = (void*)((u32*)argv->iov_base + slen); /* skip machname */ argv->iov_base = (void*)((u32*)argv->iov_base + slen); /* skip machname */
argv->iov_len -= slen*4; argv->iov_len -= slen*4;
cred->cr_uid = ntohl(svc_getu32(argv)); /* uid */ cred->cr_uid = svc_getnl(argv); /* uid */
cred->cr_gid = ntohl(svc_getu32(argv)); /* gid */ cred->cr_gid = svc_getnl(argv); /* gid */
slen = ntohl(svc_getu32(argv)); /* gids length */ slen = svc_getnl(argv); /* gids length */
if (slen > 16 || (len -= (slen + 2)*4) < 0) if (slen > 16 || (len -= (slen + 2)*4) < 0)
goto badcred; goto badcred;
cred->cr_group_info = groups_alloc(slen); cred->cr_group_info = groups_alloc(slen);
if (cred->cr_group_info == NULL) if (cred->cr_group_info == NULL)
return SVC_DROP; return SVC_DROP;
for (i = 0; i < slen; i++) for (i = 0; i < slen; i++)
GROUP_AT(cred->cr_group_info, i) = ntohl(svc_getu32(argv)); GROUP_AT(cred->cr_group_info, i) = svc_getnl(argv);
if (svc_getu32(argv) != RPC_AUTH_NULL || svc_getu32(argv) != 0) { if (svc_getu32(argv) != htonl(RPC_AUTH_NULL) || svc_getu32(argv) != 0) {
*authp = rpc_autherr_badverf; *authp = rpc_autherr_badverf;
return SVC_DENIED; return SVC_DENIED;
} }
/* Put NULL verifier */ /* Put NULL verifier */
svc_putu32(resv, RPC_AUTH_NULL); svc_putnl(resv, RPC_AUTH_NULL);
svc_putu32(resv, 0); svc_putnl(resv, 0);
return SVC_OK; return SVC_OK;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment