diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-11-04 11:20:09 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-11-04 11:20:09 -0500 |
commit | 4710e78940d8d957f24b8f085f961f1279f8fbff (patch) | |
tree | aed52541d2e7f38eadc78f71cc2565fbdd84ce0f | |
parent | 35e7452442687d7bd70f042ddfa92f89311b039c (diff) | |
parent | d3787af289c85381cc048cb8c56b67260dbbc436 (diff) |
Merge tag 'nfs-for-4.20-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
Pull NFS client bugfixes from Trond Myklebust:
"Highlights include:
Bugfix:
- Fix build issues on architectures that don't provide 64-bit cmpxchg
Cleanups:
- Fix a spelling mistake"
* tag 'nfs-for-4.20-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs:
NFS: fix spelling mistake, EACCESS -> EACCES
SUNRPC: Use atomic(64)_t for seq_send(64)
-rw-r--r-- | fs/nfs/nfs4proc.c | 2 | ||||
-rw-r--r-- | include/linux/sunrpc/gss_krb5.h | 7 | ||||
-rw-r--r-- | net/sunrpc/auth_gss/gss_krb5_mech.c | 16 | ||||
-rw-r--r-- | net/sunrpc/auth_gss/gss_krb5_seal.c | 28 | ||||
-rw-r--r-- | net/sunrpc/auth_gss/gss_krb5_wrap.c | 4 |
5 files changed, 17 insertions, 40 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index db84b4adbc49..867457d6dfbe 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -3788,7 +3788,7 @@ static int nfs4_find_root_sec(struct nfs_server *server, struct nfs_fh *fhandle, | |||
3788 | } | 3788 | } |
3789 | 3789 | ||
3790 | /* | 3790 | /* |
3791 | * -EACCESS could mean that the user doesn't have correct permissions | 3791 | * -EACCES could mean that the user doesn't have correct permissions |
3792 | * to access the mount. It could also mean that we tried to mount | 3792 | * to access the mount. It could also mean that we tried to mount |
3793 | * with a gss auth flavor, but rpc.gssd isn't running. Either way, | 3793 | * with a gss auth flavor, but rpc.gssd isn't running. Either way, |
3794 | * existing mount programs don't handle -EACCES very well so it should | 3794 | * existing mount programs don't handle -EACCES very well so it should |
diff --git a/include/linux/sunrpc/gss_krb5.h b/include/linux/sunrpc/gss_krb5.h index 131424cefc6a..02c0412e368c 100644 --- a/include/linux/sunrpc/gss_krb5.h +++ b/include/linux/sunrpc/gss_krb5.h | |||
@@ -107,8 +107,8 @@ struct krb5_ctx { | |||
107 | u8 Ksess[GSS_KRB5_MAX_KEYLEN]; /* session key */ | 107 | u8 Ksess[GSS_KRB5_MAX_KEYLEN]; /* session key */ |
108 | u8 cksum[GSS_KRB5_MAX_KEYLEN]; | 108 | u8 cksum[GSS_KRB5_MAX_KEYLEN]; |
109 | s32 endtime; | 109 | s32 endtime; |
110 | u32 seq_send; | 110 | atomic_t seq_send; |
111 | u64 seq_send64; | 111 | atomic64_t seq_send64; |
112 | struct xdr_netobj mech_used; | 112 | struct xdr_netobj mech_used; |
113 | u8 initiator_sign[GSS_KRB5_MAX_KEYLEN]; | 113 | u8 initiator_sign[GSS_KRB5_MAX_KEYLEN]; |
114 | u8 acceptor_sign[GSS_KRB5_MAX_KEYLEN]; | 114 | u8 acceptor_sign[GSS_KRB5_MAX_KEYLEN]; |
@@ -118,9 +118,6 @@ struct krb5_ctx { | |||
118 | u8 acceptor_integ[GSS_KRB5_MAX_KEYLEN]; | 118 | u8 acceptor_integ[GSS_KRB5_MAX_KEYLEN]; |
119 | }; | 119 | }; |
120 | 120 | ||
121 | extern u32 gss_seq_send_fetch_and_inc(struct krb5_ctx *ctx); | ||
122 | extern u64 gss_seq_send64_fetch_and_inc(struct krb5_ctx *ctx); | ||
123 | |||
124 | /* The length of the Kerberos GSS token header */ | 121 | /* The length of the Kerberos GSS token header */ |
125 | #define GSS_KRB5_TOK_HDR_LEN (16) | 122 | #define GSS_KRB5_TOK_HDR_LEN (16) |
126 | 123 | ||
diff --git a/net/sunrpc/auth_gss/gss_krb5_mech.c b/net/sunrpc/auth_gss/gss_krb5_mech.c index 7f0424dfa8f6..eab71fc7af3e 100644 --- a/net/sunrpc/auth_gss/gss_krb5_mech.c +++ b/net/sunrpc/auth_gss/gss_krb5_mech.c | |||
@@ -274,6 +274,7 @@ out_err: | |||
274 | static int | 274 | static int |
275 | gss_import_v1_context(const void *p, const void *end, struct krb5_ctx *ctx) | 275 | gss_import_v1_context(const void *p, const void *end, struct krb5_ctx *ctx) |
276 | { | 276 | { |
277 | u32 seq_send; | ||
277 | int tmp; | 278 | int tmp; |
278 | 279 | ||
279 | p = simple_get_bytes(p, end, &ctx->initiate, sizeof(ctx->initiate)); | 280 | p = simple_get_bytes(p, end, &ctx->initiate, sizeof(ctx->initiate)); |
@@ -315,9 +316,10 @@ gss_import_v1_context(const void *p, const void *end, struct krb5_ctx *ctx) | |||
315 | p = simple_get_bytes(p, end, &ctx->endtime, sizeof(ctx->endtime)); | 316 | p = simple_get_bytes(p, end, &ctx->endtime, sizeof(ctx->endtime)); |
316 | if (IS_ERR(p)) | 317 | if (IS_ERR(p)) |
317 | goto out_err; | 318 | goto out_err; |
318 | p = simple_get_bytes(p, end, &ctx->seq_send, sizeof(ctx->seq_send)); | 319 | p = simple_get_bytes(p, end, &seq_send, sizeof(seq_send)); |
319 | if (IS_ERR(p)) | 320 | if (IS_ERR(p)) |
320 | goto out_err; | 321 | goto out_err; |
322 | atomic_set(&ctx->seq_send, seq_send); | ||
321 | p = simple_get_netobj(p, end, &ctx->mech_used); | 323 | p = simple_get_netobj(p, end, &ctx->mech_used); |
322 | if (IS_ERR(p)) | 324 | if (IS_ERR(p)) |
323 | goto out_err; | 325 | goto out_err; |
@@ -607,6 +609,7 @@ static int | |||
607 | gss_import_v2_context(const void *p, const void *end, struct krb5_ctx *ctx, | 609 | gss_import_v2_context(const void *p, const void *end, struct krb5_ctx *ctx, |
608 | gfp_t gfp_mask) | 610 | gfp_t gfp_mask) |
609 | { | 611 | { |
612 | u64 seq_send64; | ||
610 | int keylen; | 613 | int keylen; |
611 | 614 | ||
612 | p = simple_get_bytes(p, end, &ctx->flags, sizeof(ctx->flags)); | 615 | p = simple_get_bytes(p, end, &ctx->flags, sizeof(ctx->flags)); |
@@ -617,14 +620,15 @@ gss_import_v2_context(const void *p, const void *end, struct krb5_ctx *ctx, | |||
617 | p = simple_get_bytes(p, end, &ctx->endtime, sizeof(ctx->endtime)); | 620 | p = simple_get_bytes(p, end, &ctx->endtime, sizeof(ctx->endtime)); |
618 | if (IS_ERR(p)) | 621 | if (IS_ERR(p)) |
619 | goto out_err; | 622 | goto out_err; |
620 | p = simple_get_bytes(p, end, &ctx->seq_send64, sizeof(ctx->seq_send64)); | 623 | p = simple_get_bytes(p, end, &seq_send64, sizeof(seq_send64)); |
621 | if (IS_ERR(p)) | 624 | if (IS_ERR(p)) |
622 | goto out_err; | 625 | goto out_err; |
626 | atomic64_set(&ctx->seq_send64, seq_send64); | ||
623 | /* set seq_send for use by "older" enctypes */ | 627 | /* set seq_send for use by "older" enctypes */ |
624 | ctx->seq_send = ctx->seq_send64; | 628 | atomic_set(&ctx->seq_send, seq_send64); |
625 | if (ctx->seq_send64 != ctx->seq_send) { | 629 | if (seq_send64 != atomic_read(&ctx->seq_send)) { |
626 | dprintk("%s: seq_send64 %lx, seq_send %x overflow?\n", __func__, | 630 | dprintk("%s: seq_send64 %llx, seq_send %x overflow?\n", __func__, |
627 | (unsigned long)ctx->seq_send64, ctx->seq_send); | 631 | seq_send64, atomic_read(&ctx->seq_send)); |
628 | p = ERR_PTR(-EINVAL); | 632 | p = ERR_PTR(-EINVAL); |
629 | goto out_err; | 633 | goto out_err; |
630 | } | 634 | } |
diff --git a/net/sunrpc/auth_gss/gss_krb5_seal.c b/net/sunrpc/auth_gss/gss_krb5_seal.c index b4adeb06660b..48fe4a591b54 100644 --- a/net/sunrpc/auth_gss/gss_krb5_seal.c +++ b/net/sunrpc/auth_gss/gss_krb5_seal.c | |||
@@ -123,30 +123,6 @@ setup_token_v2(struct krb5_ctx *ctx, struct xdr_netobj *token) | |||
123 | return krb5_hdr; | 123 | return krb5_hdr; |
124 | } | 124 | } |
125 | 125 | ||
126 | u32 | ||
127 | gss_seq_send_fetch_and_inc(struct krb5_ctx *ctx) | ||
128 | { | ||
129 | u32 old, seq_send = READ_ONCE(ctx->seq_send); | ||
130 | |||
131 | do { | ||
132 | old = seq_send; | ||
133 | seq_send = cmpxchg(&ctx->seq_send, old, old + 1); | ||
134 | } while (old != seq_send); | ||
135 | return seq_send; | ||
136 | } | ||
137 | |||
138 | u64 | ||
139 | gss_seq_send64_fetch_and_inc(struct krb5_ctx *ctx) | ||
140 | { | ||
141 | u64 old, seq_send = READ_ONCE(ctx->seq_send); | ||
142 | |||
143 | do { | ||
144 | old = seq_send; | ||
145 | seq_send = cmpxchg64(&ctx->seq_send64, old, old + 1); | ||
146 | } while (old != seq_send); | ||
147 | return seq_send; | ||
148 | } | ||
149 | |||
150 | static u32 | 126 | static u32 |
151 | gss_get_mic_v1(struct krb5_ctx *ctx, struct xdr_buf *text, | 127 | gss_get_mic_v1(struct krb5_ctx *ctx, struct xdr_buf *text, |
152 | struct xdr_netobj *token) | 128 | struct xdr_netobj *token) |
@@ -177,7 +153,7 @@ gss_get_mic_v1(struct krb5_ctx *ctx, struct xdr_buf *text, | |||
177 | 153 | ||
178 | memcpy(ptr + GSS_KRB5_TOK_HDR_LEN, md5cksum.data, md5cksum.len); | 154 | memcpy(ptr + GSS_KRB5_TOK_HDR_LEN, md5cksum.data, md5cksum.len); |
179 | 155 | ||
180 | seq_send = gss_seq_send_fetch_and_inc(ctx); | 156 | seq_send = atomic_fetch_inc(&ctx->seq_send); |
181 | 157 | ||
182 | if (krb5_make_seq_num(ctx, ctx->seq, ctx->initiate ? 0 : 0xff, | 158 | if (krb5_make_seq_num(ctx, ctx->seq, ctx->initiate ? 0 : 0xff, |
183 | seq_send, ptr + GSS_KRB5_TOK_HDR_LEN, ptr + 8)) | 159 | seq_send, ptr + GSS_KRB5_TOK_HDR_LEN, ptr + 8)) |
@@ -205,7 +181,7 @@ gss_get_mic_v2(struct krb5_ctx *ctx, struct xdr_buf *text, | |||
205 | 181 | ||
206 | /* Set up the sequence number. Now 64-bits in clear | 182 | /* Set up the sequence number. Now 64-bits in clear |
207 | * text and w/o direction indicator */ | 183 | * text and w/o direction indicator */ |
208 | seq_send_be64 = cpu_to_be64(gss_seq_send64_fetch_and_inc(ctx)); | 184 | seq_send_be64 = cpu_to_be64(atomic64_fetch_inc(&ctx->seq_send64)); |
209 | memcpy(krb5_hdr + 8, (char *) &seq_send_be64, 8); | 185 | memcpy(krb5_hdr + 8, (char *) &seq_send_be64, 8); |
210 | 186 | ||
211 | if (ctx->initiate) { | 187 | if (ctx->initiate) { |
diff --git a/net/sunrpc/auth_gss/gss_krb5_wrap.c b/net/sunrpc/auth_gss/gss_krb5_wrap.c index 962fa84e6db1..5cdde6cb703a 100644 --- a/net/sunrpc/auth_gss/gss_krb5_wrap.c +++ b/net/sunrpc/auth_gss/gss_krb5_wrap.c | |||
@@ -228,7 +228,7 @@ gss_wrap_kerberos_v1(struct krb5_ctx *kctx, int offset, | |||
228 | 228 | ||
229 | memcpy(ptr + GSS_KRB5_TOK_HDR_LEN, md5cksum.data, md5cksum.len); | 229 | memcpy(ptr + GSS_KRB5_TOK_HDR_LEN, md5cksum.data, md5cksum.len); |
230 | 230 | ||
231 | seq_send = gss_seq_send_fetch_and_inc(kctx); | 231 | seq_send = atomic_fetch_inc(&kctx->seq_send); |
232 | 232 | ||
233 | /* XXX would probably be more efficient to compute checksum | 233 | /* XXX would probably be more efficient to compute checksum |
234 | * and encrypt at the same time: */ | 234 | * and encrypt at the same time: */ |
@@ -475,7 +475,7 @@ gss_wrap_kerberos_v2(struct krb5_ctx *kctx, u32 offset, | |||
475 | *be16ptr++ = 0; | 475 | *be16ptr++ = 0; |
476 | 476 | ||
477 | be64ptr = (__be64 *)be16ptr; | 477 | be64ptr = (__be64 *)be16ptr; |
478 | *be64ptr = cpu_to_be64(gss_seq_send64_fetch_and_inc(kctx)); | 478 | *be64ptr = cpu_to_be64(atomic64_fetch_inc(&kctx->seq_send64)); |
479 | 479 | ||
480 | err = (*kctx->gk5e->encrypt_v2)(kctx, offset, buf, pages); | 480 | err = (*kctx->gk5e->encrypt_v2)(kctx, offset, buf, pages); |
481 | if (err) | 481 | if (err) |