aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@fieldses.org>2006-12-04 20:22:40 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-12-06 10:46:47 -0500
commitd922a84a8bf1d627810906d033223d4fa629fdbf (patch)
tree8150e29f36f3e14df0c1fea1caa1936f7cfa0e3a
parent39a21dd1b0eec3f5eac84ee42bda5ab4915098ae (diff)
rpcgss: krb5: sanity check sealalg value in the downcall
The sealalg is checked in several places, giving the impression it could be either SEAL_ALG_NONE or SEAL_ALG_DES. But in fact SEAL_ALG_NONE seems to be sufficient only for making mic's, and all the contexts we get must be capable of wrapping as well. So the sealalg must be SEAL_ALG_DES. As with signalg, just check for the right value on the downcall and ignore it otherwise. Similarly, tighten expectations for the sealalg on incoming tokens, in case we do support other values eventually. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--include/linux/sunrpc/gss_krb5.h1
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_mech.c4
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_seal.c6
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_wrap.c25
4 files changed, 5 insertions, 31 deletions
diff --git a/include/linux/sunrpc/gss_krb5.h b/include/linux/sunrpc/gss_krb5.h
index abfa1f32d914..01c5e4314632 100644
--- a/include/linux/sunrpc/gss_krb5.h
+++ b/include/linux/sunrpc/gss_krb5.h
@@ -44,7 +44,6 @@ struct krb5_ctx {
44 int initiate; /* 1 = initiating, 0 = accepting */ 44 int initiate; /* 1 = initiating, 0 = accepting */
45 int seed_init; 45 int seed_init;
46 unsigned char seed[16]; 46 unsigned char seed[16];
47 int sealalg;
48 struct crypto_blkcipher *enc; 47 struct crypto_blkcipher *enc;
49 struct crypto_blkcipher *seq; 48 struct crypto_blkcipher *seq;
50 s32 endtime; 49 s32 endtime;
diff --git a/net/sunrpc/auth_gss/gss_krb5_mech.c b/net/sunrpc/auth_gss/gss_krb5_mech.c
index 17587163fcae..bf5435db8785 100644
--- a/net/sunrpc/auth_gss/gss_krb5_mech.c
+++ b/net/sunrpc/auth_gss/gss_krb5_mech.c
@@ -148,9 +148,11 @@ gss_import_sec_context_kerberos(const void *p,
148 goto out_err_free_ctx; 148 goto out_err_free_ctx;
149 if (tmp != SGN_ALG_DES_MAC_MD5) 149 if (tmp != SGN_ALG_DES_MAC_MD5)
150 goto out_err_free_ctx; 150 goto out_err_free_ctx;
151 p = simple_get_bytes(p, end, &ctx->sealalg, sizeof(ctx->sealalg)); 151 p = simple_get_bytes(p, end, &tmp, sizeof(tmp));
152 if (IS_ERR(p)) 152 if (IS_ERR(p))
153 goto out_err_free_ctx; 153 goto out_err_free_ctx;
154 if (tmp != SEAL_ALG_DES)
155 goto out_err_free_ctx;
154 p = simple_get_bytes(p, end, &ctx->endtime, sizeof(ctx->endtime)); 156 p = simple_get_bytes(p, end, &ctx->endtime, sizeof(ctx->endtime));
155 if (IS_ERR(p)) 157 if (IS_ERR(p))
156 goto out_err_free_ctx; 158 goto out_err_free_ctx;
diff --git a/net/sunrpc/auth_gss/gss_krb5_seal.c b/net/sunrpc/auth_gss/gss_krb5_seal.c
index f3f42a4465cf..f42e453e63ea 100644
--- a/net/sunrpc/auth_gss/gss_krb5_seal.c
+++ b/net/sunrpc/auth_gss/gss_krb5_seal.c
@@ -87,12 +87,6 @@ gss_get_mic_kerberos(struct gss_ctx *gss_ctx, struct xdr_buf *text,
87 87
88 now = get_seconds(); 88 now = get_seconds();
89 89
90 if (ctx->sealalg != SEAL_ALG_NONE && ctx->sealalg != SEAL_ALG_DES) {
91 dprintk("RPC: gss_krb5_seal: ctx->sealalg %d not supported\n",
92 ctx->sealalg);
93 return GSS_S_FAILURE;
94 }
95
96 token->len = g_token_size(&ctx->mech_used, 22); 90 token->len = g_token_size(&ctx->mech_used, 22);
97 91
98 ptr = token->data; 92 ptr = token->data;
diff --git a/net/sunrpc/auth_gss/gss_krb5_wrap.c b/net/sunrpc/auth_gss/gss_krb5_wrap.c
index 63b06ee2d542..bf25f4d9acd1 100644
--- a/net/sunrpc/auth_gss/gss_krb5_wrap.c
+++ b/net/sunrpc/auth_gss/gss_krb5_wrap.c
@@ -133,12 +133,6 @@ gss_wrap_kerberos(struct gss_ctx *ctx, int offset,
133 133
134 now = get_seconds(); 134 now = get_seconds();
135 135
136 if (kctx->sealalg != SEAL_ALG_NONE && kctx->sealalg != SEAL_ALG_DES) {
137 dprintk("RPC: gss_krb5_seal: kctx->sealalg %d not supported\n",
138 kctx->sealalg);
139 return GSS_S_FAILURE;
140 }
141
142 blocksize = crypto_blkcipher_blocksize(kctx->enc); 136 blocksize = crypto_blkcipher_blocksize(kctx->enc);
143 gss_krb5_add_padding(buf, offset, blocksize); 137 gss_krb5_add_padding(buf, offset, blocksize);
144 BUG_ON((buf->len - offset) % blocksize); 138 BUG_ON((buf->len - offset) % blocksize);
@@ -169,7 +163,7 @@ gss_wrap_kerberos(struct gss_ctx *ctx, int offset,
169 163
170 *(__be16 *)(krb5_hdr + 2) = htons(SGN_ALG_DES_MAC_MD5); 164 *(__be16 *)(krb5_hdr + 2) = htons(SGN_ALG_DES_MAC_MD5);
171 memset(krb5_hdr + 4, 0xff, 4); 165 memset(krb5_hdr + 4, 0xff, 4);
172 *(__be16 *)(krb5_hdr + 4) = htons(kctx->sealalg); 166 *(__be16 *)(krb5_hdr + 4) = htons(SEAL_ALG_DES);
173 167
174 make_confounder(msg_start, blocksize); 168 make_confounder(msg_start, blocksize);
175 169
@@ -245,26 +239,11 @@ gss_unwrap_kerberos(struct gss_ctx *ctx, int offset, struct xdr_buf *buf)
245 if ((ptr[4] != 0xff) || (ptr[5] != 0xff)) 239 if ((ptr[4] != 0xff) || (ptr[5] != 0xff))
246 return GSS_S_DEFECTIVE_TOKEN; 240 return GSS_S_DEFECTIVE_TOKEN;
247 241
248 if (sealalg == 0xffff) 242 if (sealalg != SEAL_ALG_DES)
249 return GSS_S_DEFECTIVE_TOKEN; 243 return GSS_S_DEFECTIVE_TOKEN;
250 if (signalg != SGN_ALG_DES_MAC_MD5) 244 if (signalg != SGN_ALG_DES_MAC_MD5)
251 return GSS_S_DEFECTIVE_TOKEN; 245 return GSS_S_DEFECTIVE_TOKEN;
252 246
253 /* in the current spec, there is only one valid seal algorithm per
254 key type, so a simple comparison is ok */
255
256 if (sealalg != kctx->sealalg)
257 return GSS_S_DEFECTIVE_TOKEN;
258
259 /* there are several mappings of seal algorithms to sign algorithms,
260 but few enough that we can try them all. */
261
262 if ((kctx->sealalg == SEAL_ALG_NONE && signalg > 1) ||
263 (kctx->sealalg == SEAL_ALG_1 && signalg != SGN_ALG_3) ||
264 (kctx->sealalg == SEAL_ALG_DES3KD &&
265 signalg != SGN_ALG_HMAC_SHA1_DES3_KD))
266 return GSS_S_DEFECTIVE_TOKEN;
267
268 if (gss_decrypt_xdr_buf(kctx->enc, buf, 247 if (gss_decrypt_xdr_buf(kctx->enc, buf,
269 ptr + 22 - (unsigned char *)buf->head[0].iov_base)) 248 ptr + 22 - (unsigned char *)buf->head[0].iov_base))
270 return GSS_S_DEFECTIVE_TOKEN; 249 return GSS_S_DEFECTIVE_TOKEN;