Skip to content

Commit 4710e78

Browse files
committed
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)
2 parents 35e7452 + d3787af commit 4710e78

File tree

5 files changed

+17
-40
lines changed

5 files changed

+17
-40
lines changed

fs/nfs/nfs4proc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3788,7 +3788,7 @@ static int nfs4_find_root_sec(struct nfs_server *server, struct nfs_fh *fhandle,
37883788
}
37893789

37903790
/*
3791-
* -EACCESS could mean that the user doesn't have correct permissions
3791+
* -EACCES could mean that the user doesn't have correct permissions
37923792
* to access the mount. It could also mean that we tried to mount
37933793
* with a gss auth flavor, but rpc.gssd isn't running. Either way,
37943794
* existing mount programs don't handle -EACCES very well so it should

include/linux/sunrpc/gss_krb5.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ struct krb5_ctx {
107107
u8 Ksess[GSS_KRB5_MAX_KEYLEN]; /* session key */
108108
u8 cksum[GSS_KRB5_MAX_KEYLEN];
109109
s32 endtime;
110-
u32 seq_send;
111-
u64 seq_send64;
110+
atomic_t seq_send;
111+
atomic64_t seq_send64;
112112
struct xdr_netobj mech_used;
113113
u8 initiator_sign[GSS_KRB5_MAX_KEYLEN];
114114
u8 acceptor_sign[GSS_KRB5_MAX_KEYLEN];
@@ -118,9 +118,6 @@ struct krb5_ctx {
118118
u8 acceptor_integ[GSS_KRB5_MAX_KEYLEN];
119119
};
120120

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-
124121
/* The length of the Kerberos GSS token header */
125122
#define GSS_KRB5_TOK_HDR_LEN (16)
126123

net/sunrpc/auth_gss/gss_krb5_mech.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ get_key(const void *p, const void *end,
274274
static int
275275
gss_import_v1_context(const void *p, const void *end, struct krb5_ctx *ctx)
276276
{
277+
u32 seq_send;
277278
int tmp;
278279

279280
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)
315316
p = simple_get_bytes(p, end, &ctx->endtime, sizeof(ctx->endtime));
316317
if (IS_ERR(p))
317318
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));
319320
if (IS_ERR(p))
320321
goto out_err;
322+
atomic_set(&ctx->seq_send, seq_send);
321323
p = simple_get_netobj(p, end, &ctx->mech_used);
322324
if (IS_ERR(p))
323325
goto out_err;
@@ -607,6 +609,7 @@ static int
607609
gss_import_v2_context(const void *p, const void *end, struct krb5_ctx *ctx,
608610
gfp_t gfp_mask)
609611
{
612+
u64 seq_send64;
610613
int keylen;
611614

612615
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,
617620
p = simple_get_bytes(p, end, &ctx->endtime, sizeof(ctx->endtime));
618621
if (IS_ERR(p))
619622
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));
621624
if (IS_ERR(p))
622625
goto out_err;
626+
atomic64_set(&ctx->seq_send64, seq_send64);
623627
/* set seq_send for use by "older" enctypes */
624-
ctx->seq_send = ctx->seq_send64;
625-
if (ctx->seq_send64 != ctx->seq_send) {
626-
dprintk("%s: seq_send64 %lx, seq_send %x overflow?\n", __func__,
627-
(unsigned long)ctx->seq_send64, ctx->seq_send);
628+
atomic_set(&ctx->seq_send, seq_send64);
629+
if (seq_send64 != atomic_read(&ctx->seq_send)) {
630+
dprintk("%s: seq_send64 %llx, seq_send %x overflow?\n", __func__,
631+
seq_send64, atomic_read(&ctx->seq_send));
628632
p = ERR_PTR(-EINVAL);
629633
goto out_err;
630634
}

net/sunrpc/auth_gss/gss_krb5_seal.c

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -123,30 +123,6 @@ setup_token_v2(struct krb5_ctx *ctx, struct xdr_netobj *token)
123123
return krb5_hdr;
124124
}
125125

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-
150126
static u32
151127
gss_get_mic_v1(struct krb5_ctx *ctx, struct xdr_buf *text,
152128
struct xdr_netobj *token)
@@ -177,7 +153,7 @@ gss_get_mic_v1(struct krb5_ctx *ctx, struct xdr_buf *text,
177153

178154
memcpy(ptr + GSS_KRB5_TOK_HDR_LEN, md5cksum.data, md5cksum.len);
179155

180-
seq_send = gss_seq_send_fetch_and_inc(ctx);
156+
seq_send = atomic_fetch_inc(&ctx->seq_send);
181157

182158
if (krb5_make_seq_num(ctx, ctx->seq, ctx->initiate ? 0 : 0xff,
183159
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,
205181

206182
/* Set up the sequence number. Now 64-bits in clear
207183
* 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));
209185
memcpy(krb5_hdr + 8, (char *) &seq_send_be64, 8);
210186

211187
if (ctx->initiate) {

net/sunrpc/auth_gss/gss_krb5_wrap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ gss_wrap_kerberos_v1(struct krb5_ctx *kctx, int offset,
228228

229229
memcpy(ptr + GSS_KRB5_TOK_HDR_LEN, md5cksum.data, md5cksum.len);
230230

231-
seq_send = gss_seq_send_fetch_and_inc(kctx);
231+
seq_send = atomic_fetch_inc(&kctx->seq_send);
232232

233233
/* XXX would probably be more efficient to compute checksum
234234
* and encrypt at the same time: */
@@ -475,7 +475,7 @@ gss_wrap_kerberos_v2(struct krb5_ctx *kctx, u32 offset,
475475
*be16ptr++ = 0;
476476

477477
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));
479479

480480
err = (*kctx->gk5e->encrypt_v2)(kctx, offset, buf, pages);
481481
if (err)

0 commit comments

Comments
 (0)