Pull more nfsd fixes from Bruce Fields: "Two small fixes, one for crashes using nfs/krb5 with older enctypes, one that could prevent clients from reclaiming state after a kernel upgrade" * tag 'nfsd-5.0-2' of git://linux-nfs.org/~bfields/linux: sunrpc: fix 4 more call sites that were using stack memory with a scatterlist Revert "nfsd4: return default lease period"
Unified · Split
| @@ -1239,8 +1239,8 @@ static __net_init int nfsd_init_net(struct net *net) · 1238 unmodified lines | ||
| 1239 | 1239 | retval = nfsd_idmap_init(net); |
| 1240 | 1240 | if (retval) |
| 1241 | 1241 | goto out_idmap_error; |
| 1242 | − nn->nfsd4_lease = 45; /* default lease time */ | |
| 1243 | − nn->nfsd4_grace = 45; | |
| 1242 | + nn->nfsd4_lease = 90; /* default lease time */ | |
| 1243 | + nn->nfsd4_grace = 90; | |
| 1244 | 1244 | nn->somebody_reclaimed = false; |
| 1245 | 1245 | nn->clverifier_counter = prandom_u32(); |
| 1246 | 1246 | nn->clientid_counter = prandom_u32(); |
| @@ -44,7 +44,7 @@ krb5_make_rc4_seq_num(struct krb5_ctx *kctx, int direction, s32 seqnum, · 43 unmodified lines | ||
| 44 | 44 | unsigned char *cksum, unsigned char *buf) |
| 45 | 45 | { |
| 46 | 46 | struct crypto_sync_skcipher *cipher; |
| 47 | − unsigned char plain[8]; | |
| 47 | + unsigned char *plain; | |
| 48 | 48 | s32 code; |
| 49 | 49 | |
| 50 | 50 | dprintk("RPC: %s:\n", __func__); |
| @@ -52,6 +52,10 @@ krb5_make_rc4_seq_num(struct krb5_ctx *kctx, int direction, s32 seqnum, · 1 unmodified line | ||
| 52 | 52 | if (IS_ERR(cipher)) |
| 53 | 53 | return PTR_ERR(cipher); |
| 54 | 54 | |
| 55 | + plain = kmalloc(8, GFP_NOFS); | |
| 56 | + if (!plain) | |
| 57 | + return -ENOMEM; | |
| 58 | + | |
| 55 | 59 | plain[0] = (unsigned char) ((seqnum >> 24) & 0xff); |
| 56 | 60 | plain[1] = (unsigned char) ((seqnum >> 16) & 0xff); |
| 57 | 61 | plain[2] = (unsigned char) ((seqnum >> 8) & 0xff); |
| @@ -67,6 +71,7 @@ krb5_make_rc4_seq_num(struct krb5_ctx *kctx, int direction, s32 seqnum, · 9 unmodified lines | ||
| 67 | 71 | |
| 68 | 72 | code = krb5_encrypt(cipher, cksum, plain, buf, 8); |
| 69 | 73 | out: |
| 74 | + kfree(plain); | |
| 70 | 75 | crypto_free_sync_skcipher(cipher); |
| 71 | 76 | return code; |
| 72 | 77 | } |
| @@ -77,12 +82,17 @@ krb5_make_seq_num(struct krb5_ctx *kctx, · 4 unmodified lines | ||
| 77 | 82 | u32 seqnum, |
| 78 | 83 | unsigned char *cksum, unsigned char *buf) |
| 79 | 84 | { |
| 80 | − unsigned char plain[8]; | |
| 85 | + unsigned char *plain; | |
| 86 | + s32 code; | |
| 81 | 87 | |
| 82 | 88 | if (kctx->enctype == ENCTYPE_ARCFOUR_HMAC) |
| 83 | 89 | return krb5_make_rc4_seq_num(kctx, direction, seqnum, |
| 84 | 90 | cksum, buf); |
| 85 | 91 | |
| 92 | + plain = kmalloc(8, GFP_NOFS); | |
| 93 | + if (!plain) | |
| 94 | + return -ENOMEM; | |
| 95 | + | |
| 86 | 96 | plain[0] = (unsigned char) (seqnum & 0xff); |
| 87 | 97 | plain[1] = (unsigned char) ((seqnum >> 8) & 0xff); |
| 88 | 98 | plain[2] = (unsigned char) ((seqnum >> 16) & 0xff); |
| @@ -93,7 +103,9 @@ krb5_make_seq_num(struct krb5_ctx *kctx, · 4 unmodified lines | ||
| 93 | 103 | plain[6] = direction; |
| 94 | 104 | plain[7] = direction; |
| 95 | 105 | |
| 96 | − return krb5_encrypt(key, cksum, plain, buf, 8); | |
| 106 | + code = krb5_encrypt(key, cksum, plain, buf, 8); | |
| 107 | + kfree(plain); | |
| 108 | + return code; | |
| 97 | 109 | } |
| 98 | 110 | |
| 99 | 111 | static s32 |
| @@ -101,7 +113,7 @@ krb5_get_rc4_seq_num(struct krb5_ctx *kctx, unsigned char *cksum, · 1 unmodified line | ||
| 101 | 113 | unsigned char *buf, int *direction, s32 *seqnum) |
| 102 | 114 | { |
| 103 | 115 | struct crypto_sync_skcipher *cipher; |
| 104 | − unsigned char plain[8]; | |
| 116 | + unsigned char *plain; | |
| 105 | 117 | s32 code; |
| 106 | 118 | |
| 107 | 119 | dprintk("RPC: %s:\n", __func__); |
| @@ -113,20 +125,28 @@ krb5_get_rc4_seq_num(struct krb5_ctx *kctx, unsigned char *cksum, · 5 unmodified lines | ||
| 113 | 125 | if (code) |
| 114 | 126 | goto out; |
| 115 | 127 | |
| 128 | + plain = kmalloc(8, GFP_NOFS); | |
| 129 | + if (!plain) { | |
| 130 | + code = -ENOMEM; | |
| 131 | + goto out; | |
| 132 | + } | |
| 133 | + | |
| 116 | 134 | code = krb5_decrypt(cipher, cksum, buf, plain, 8); |
| 117 | 135 | if (code) |
| 118 | − goto out; | |
| 136 | + goto out_plain; | |
| 119 | 137 | |
| 120 | 138 | if ((plain[4] != plain[5]) || (plain[4] != plain[6]) |
| 121 | 139 | || (plain[4] != plain[7])) { |
| 122 | 140 | code = (s32)KG_BAD_SEQ; |
| 123 | − goto out; | |
| 141 | + goto out_plain; | |
| 124 | 142 | } |
| 125 | 143 | |
| 126 | 144 | *direction = plain[4]; |
| 127 | 145 | |
| 128 | 146 | *seqnum = ((plain[0] << 24) | (plain[1] << 16) | |
| 129 | 147 | (plain[2] << 8) | (plain[3])); |
| 148 | +out_plain: | |
| 149 | + kfree(plain); | |
| 130 | 150 | out: |
| 131 | 151 | crypto_free_sync_skcipher(cipher); |
| 132 | 152 | return code; |
| @@ -139,7 +159,7 @@ krb5_get_seq_num(struct krb5_ctx *kctx, · 6 unmodified lines | ||
| 139 | 159 | int *direction, u32 *seqnum) |
| 140 | 160 | { |
| 141 | 161 | s32 code; |
| 142 | − unsigned char plain[8]; | |
| 162 | + unsigned char *plain; | |
| 143 | 163 | struct crypto_sync_skcipher *key = kctx->seq; |
| 144 | 164 | |
| 145 | 165 | dprintk("RPC: krb5_get_seq_num:\n"); |
| @@ -147,18 +167,25 @@ krb5_get_seq_num(struct krb5_ctx *kctx, · 1 unmodified line | ||
| 147 | 167 | if (kctx->enctype == ENCTYPE_ARCFOUR_HMAC) |
| 148 | 168 | return krb5_get_rc4_seq_num(kctx, cksum, buf, |
| 149 | 169 | direction, seqnum); |
| 170 | + plain = kmalloc(8, GFP_NOFS); | |
| 171 | + if (!plain) | |
| 172 | + return -ENOMEM; | |
| 150 | 173 | |
| 151 | 174 | if ((code = krb5_decrypt(key, cksum, buf, plain, 8))) |
| 152 | − return code; | |
| 175 | + goto out; | |
| 153 | 176 | |
| 154 | 177 | if ((plain[4] != plain[5]) || (plain[4] != plain[6]) || |
| 155 | − (plain[4] != plain[7])) | |
| 156 | − return (s32)KG_BAD_SEQ; | |
| 178 | + (plain[4] != plain[7])) { | |
| 179 | + code = (s32)KG_BAD_SEQ; | |
| 180 | + goto out; | |
| 181 | + } | |
| 157 | 182 | |
| 158 | 183 | *direction = plain[4]; |
| 159 | 184 | |
| 160 | 185 | *seqnum = ((plain[0]) | |
| 161 | 186 | (plain[1] << 8) | (plain[2] << 16) | (plain[3] << 24)); |
| 162 | 187 | |
| 163 | − return 0; | |
| 188 | +out: | |
| 189 | + kfree(plain); | |
| 190 | + return code; | |
| 164 | 191 | } |