]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/checksum.c
Update bcachefs sources to 7c0fe6f104 bcachefs: Fix bch2_fsck_ask_yn()
[bcachefs-tools-debian] / libbcachefs / checksum.c
1 // SPDX-License-Identifier: GPL-2.0
2 #include "bcachefs.h"
3 #include "checksum.h"
4 #include "errcode.h"
5 #include "super.h"
6 #include "super-io.h"
7
8 #include <linux/crc32c.h>
9 #include <linux/crypto.h>
10 #include <linux/xxhash.h>
11 #include <linux/key.h>
12 #include <linux/random.h>
13 #include <linux/scatterlist.h>
14 #include <crypto/algapi.h>
15 #include <crypto/chacha.h>
16 #include <crypto/hash.h>
17 #include <crypto/poly1305.h>
18 #include <crypto/skcipher.h>
19 #include <keys/user-type.h>
20
21 /*
22  * bch2_checksum state is an abstraction of the checksum state calculated over different pages.
23  * it features page merging without having the checksum algorithm lose its state.
24  * for native checksum aglorithms (like crc), a default seed value will do.
25  * for hash-like algorithms, a state needs to be stored
26  */
27
28 struct bch2_checksum_state {
29         union {
30                 u64 seed;
31                 struct xxh64_state h64state;
32         };
33         unsigned int type;
34 };
35
36 static void bch2_checksum_init(struct bch2_checksum_state *state)
37 {
38         switch (state->type) {
39         case BCH_CSUM_none:
40         case BCH_CSUM_crc32c:
41         case BCH_CSUM_crc64:
42                 state->seed = 0;
43                 break;
44         case BCH_CSUM_crc32c_nonzero:
45                 state->seed = U32_MAX;
46                 break;
47         case BCH_CSUM_crc64_nonzero:
48                 state->seed = U64_MAX;
49                 break;
50         case BCH_CSUM_xxhash:
51                 xxh64_reset(&state->h64state, 0);
52                 break;
53         default:
54                 BUG();
55         }
56 }
57
58 static u64 bch2_checksum_final(const struct bch2_checksum_state *state)
59 {
60         switch (state->type) {
61         case BCH_CSUM_none:
62         case BCH_CSUM_crc32c:
63         case BCH_CSUM_crc64:
64                 return state->seed;
65         case BCH_CSUM_crc32c_nonzero:
66                 return state->seed ^ U32_MAX;
67         case BCH_CSUM_crc64_nonzero:
68                 return state->seed ^ U64_MAX;
69         case BCH_CSUM_xxhash:
70                 return xxh64_digest(&state->h64state);
71         default:
72                 BUG();
73         }
74 }
75
76 static void bch2_checksum_update(struct bch2_checksum_state *state, const void *data, size_t len)
77 {
78         switch (state->type) {
79         case BCH_CSUM_none:
80                 return;
81         case BCH_CSUM_crc32c_nonzero:
82         case BCH_CSUM_crc32c:
83                 state->seed = crc32c(state->seed, data, len);
84                 break;
85         case BCH_CSUM_crc64_nonzero:
86         case BCH_CSUM_crc64:
87                 state->seed = crc64_be(state->seed, data, len);
88                 break;
89         case BCH_CSUM_xxhash:
90                 xxh64_update(&state->h64state, data, len);
91                 break;
92         default:
93                 BUG();
94         }
95 }
96
97 static inline int do_encrypt_sg(struct crypto_sync_skcipher *tfm,
98                                 struct nonce nonce,
99                                 struct scatterlist *sg, size_t len)
100 {
101         SYNC_SKCIPHER_REQUEST_ON_STACK(req, tfm);
102         int ret;
103
104         skcipher_request_set_sync_tfm(req, tfm);
105         skcipher_request_set_crypt(req, sg, sg, len, nonce.d);
106
107         ret = crypto_skcipher_encrypt(req);
108         if (ret)
109                 pr_err("got error %i from crypto_skcipher_encrypt()", ret);
110
111         return ret;
112 }
113
114 static inline int do_encrypt(struct crypto_sync_skcipher *tfm,
115                               struct nonce nonce,
116                               void *buf, size_t len)
117 {
118         if (!is_vmalloc_addr(buf)) {
119                 struct scatterlist sg;
120
121                 sg_init_table(&sg, 1);
122                 sg_set_page(&sg,
123                             is_vmalloc_addr(buf)
124                             ? vmalloc_to_page(buf)
125                             : virt_to_page(buf),
126                             len, offset_in_page(buf));
127                 return do_encrypt_sg(tfm, nonce, &sg, len);
128         } else {
129                 unsigned pages = buf_pages(buf, len);
130                 struct scatterlist *sg;
131                 size_t orig_len = len;
132                 int ret, i;
133
134                 sg = kmalloc_array(pages, sizeof(*sg), GFP_KERNEL);
135                 if (!sg)
136                         return -BCH_ERR_ENOMEM_do_encrypt;
137
138                 sg_init_table(sg, pages);
139
140                 for (i = 0; i < pages; i++) {
141                         unsigned offset = offset_in_page(buf);
142                         unsigned pg_len = min(len, PAGE_SIZE - offset);
143
144                         sg_set_page(sg + i, vmalloc_to_page(buf), pg_len, offset);
145                         buf += pg_len;
146                         len -= pg_len;
147                 }
148
149                 ret = do_encrypt_sg(tfm, nonce, sg, orig_len);
150                 kfree(sg);
151                 return ret;
152         }
153 }
154
155 int bch2_chacha_encrypt_key(struct bch_key *key, struct nonce nonce,
156                             void *buf, size_t len)
157 {
158         struct crypto_sync_skcipher *chacha20 =
159                 crypto_alloc_sync_skcipher("chacha20", 0, 0);
160         int ret;
161
162         if (!chacha20) {
163                 pr_err("error requesting chacha20 module: %li", PTR_ERR(chacha20));
164                 return PTR_ERR(chacha20);
165         }
166
167         ret = crypto_skcipher_setkey(&chacha20->base,
168                                      (void *) key, sizeof(*key));
169         if (ret) {
170                 pr_err("crypto_skcipher_setkey() error: %i", ret);
171                 goto err;
172         }
173
174         ret = do_encrypt(chacha20, nonce, buf, len);
175 err:
176         crypto_free_sync_skcipher(chacha20);
177         return ret;
178 }
179
180 static int gen_poly_key(struct bch_fs *c, struct shash_desc *desc,
181                         struct nonce nonce)
182 {
183         u8 key[POLY1305_KEY_SIZE];
184         int ret;
185
186         nonce.d[3] ^= BCH_NONCE_POLY;
187
188         memset(key, 0, sizeof(key));
189         ret = do_encrypt(c->chacha20, nonce, key, sizeof(key));
190         if (ret)
191                 return ret;
192
193         desc->tfm = c->poly1305;
194         crypto_shash_init(desc);
195         crypto_shash_update(desc, key, sizeof(key));
196         return 0;
197 }
198
199 struct bch_csum bch2_checksum(struct bch_fs *c, unsigned type,
200                               struct nonce nonce, const void *data, size_t len)
201 {
202         switch (type) {
203         case BCH_CSUM_none:
204         case BCH_CSUM_crc32c_nonzero:
205         case BCH_CSUM_crc64_nonzero:
206         case BCH_CSUM_crc32c:
207         case BCH_CSUM_xxhash:
208         case BCH_CSUM_crc64: {
209                 struct bch2_checksum_state state;
210
211                 state.type = type;
212
213                 bch2_checksum_init(&state);
214                 bch2_checksum_update(&state, data, len);
215
216                 return (struct bch_csum) { .lo = cpu_to_le64(bch2_checksum_final(&state)) };
217         }
218
219         case BCH_CSUM_chacha20_poly1305_80:
220         case BCH_CSUM_chacha20_poly1305_128: {
221                 SHASH_DESC_ON_STACK(desc, c->poly1305);
222                 u8 digest[POLY1305_DIGEST_SIZE];
223                 struct bch_csum ret = { 0 };
224
225                 gen_poly_key(c, desc, nonce);
226
227                 crypto_shash_update(desc, data, len);
228                 crypto_shash_final(desc, digest);
229
230                 memcpy(&ret, digest, bch_crc_bytes[type]);
231                 return ret;
232         }
233         default:
234                 BUG();
235         }
236 }
237
238 int bch2_encrypt(struct bch_fs *c, unsigned type,
239                   struct nonce nonce, void *data, size_t len)
240 {
241         if (!bch2_csum_type_is_encryption(type))
242                 return 0;
243
244         return do_encrypt(c->chacha20, nonce, data, len);
245 }
246
247 static struct bch_csum __bch2_checksum_bio(struct bch_fs *c, unsigned type,
248                                            struct nonce nonce, struct bio *bio,
249                                            struct bvec_iter *iter)
250 {
251         struct bio_vec bv;
252
253         switch (type) {
254         case BCH_CSUM_none:
255                 return (struct bch_csum) { 0 };
256         case BCH_CSUM_crc32c_nonzero:
257         case BCH_CSUM_crc64_nonzero:
258         case BCH_CSUM_crc32c:
259         case BCH_CSUM_xxhash:
260         case BCH_CSUM_crc64: {
261                 struct bch2_checksum_state state;
262
263                 state.type = type;
264                 bch2_checksum_init(&state);
265
266 #ifdef CONFIG_HIGHMEM
267                 __bio_for_each_segment(bv, bio, *iter, *iter) {
268                         void *p = kmap_atomic(bv.bv_page) + bv.bv_offset;
269                         bch2_checksum_update(&state, p, bv.bv_len);
270                         kunmap_atomic(p);
271                 }
272 #else
273                 __bio_for_each_bvec(bv, bio, *iter, *iter)
274                         bch2_checksum_update(&state, page_address(bv.bv_page) + bv.bv_offset,
275                                 bv.bv_len);
276 #endif
277                 return (struct bch_csum) { .lo = cpu_to_le64(bch2_checksum_final(&state)) };
278         }
279
280         case BCH_CSUM_chacha20_poly1305_80:
281         case BCH_CSUM_chacha20_poly1305_128: {
282                 SHASH_DESC_ON_STACK(desc, c->poly1305);
283                 u8 digest[POLY1305_DIGEST_SIZE];
284                 struct bch_csum ret = { 0 };
285
286                 gen_poly_key(c, desc, nonce);
287
288 #ifdef CONFIG_HIGHMEM
289                 __bio_for_each_segment(bv, bio, *iter, *iter) {
290                         void *p = kmap_atomic(bv.bv_page) + bv.bv_offset;
291
292                         crypto_shash_update(desc, p, bv.bv_len);
293                         kunmap_atomic(p);
294                 }
295 #else
296                 __bio_for_each_bvec(bv, bio, *iter, *iter)
297                         crypto_shash_update(desc,
298                                 page_address(bv.bv_page) + bv.bv_offset,
299                                 bv.bv_len);
300 #endif
301                 crypto_shash_final(desc, digest);
302
303                 memcpy(&ret, digest, bch_crc_bytes[type]);
304                 return ret;
305         }
306         default:
307                 BUG();
308         }
309 }
310
311 struct bch_csum bch2_checksum_bio(struct bch_fs *c, unsigned type,
312                                   struct nonce nonce, struct bio *bio)
313 {
314         struct bvec_iter iter = bio->bi_iter;
315
316         return __bch2_checksum_bio(c, type, nonce, bio, &iter);
317 }
318
319 int __bch2_encrypt_bio(struct bch_fs *c, unsigned type,
320                      struct nonce nonce, struct bio *bio)
321 {
322         struct bio_vec bv;
323         struct bvec_iter iter;
324         struct scatterlist sgl[16], *sg = sgl;
325         size_t bytes = 0;
326         int ret = 0;
327
328         if (!bch2_csum_type_is_encryption(type))
329                 return 0;
330
331         sg_init_table(sgl, ARRAY_SIZE(sgl));
332
333         bio_for_each_segment(bv, bio, iter) {
334                 if (sg == sgl + ARRAY_SIZE(sgl)) {
335                         sg_mark_end(sg - 1);
336
337                         ret = do_encrypt_sg(c->chacha20, nonce, sgl, bytes);
338                         if (ret)
339                                 return ret;
340
341                         nonce = nonce_add(nonce, bytes);
342                         bytes = 0;
343
344                         sg_init_table(sgl, ARRAY_SIZE(sgl));
345                         sg = sgl;
346                 }
347
348                 sg_set_page(sg++, bv.bv_page, bv.bv_len, bv.bv_offset);
349                 bytes += bv.bv_len;
350         }
351
352         sg_mark_end(sg - 1);
353         return do_encrypt_sg(c->chacha20, nonce, sgl, bytes);
354 }
355
356 struct bch_csum bch2_checksum_merge(unsigned type, struct bch_csum a,
357                                     struct bch_csum b, size_t b_len)
358 {
359         struct bch2_checksum_state state;
360
361         state.type = type;
362         bch2_checksum_init(&state);
363         state.seed = a.lo;
364
365         BUG_ON(!bch2_checksum_mergeable(type));
366
367         while (b_len) {
368                 unsigned b = min_t(unsigned, b_len, PAGE_SIZE);
369
370                 bch2_checksum_update(&state,
371                                 page_address(ZERO_PAGE(0)), b);
372                 b_len -= b;
373         }
374         a.lo = bch2_checksum_final(&state);
375         a.lo ^= b.lo;
376         a.hi ^= b.hi;
377         return a;
378 }
379
380 int bch2_rechecksum_bio(struct bch_fs *c, struct bio *bio,
381                         struct bversion version,
382                         struct bch_extent_crc_unpacked crc_old,
383                         struct bch_extent_crc_unpacked *crc_a,
384                         struct bch_extent_crc_unpacked *crc_b,
385                         unsigned len_a, unsigned len_b,
386                         unsigned new_csum_type)
387 {
388         struct bvec_iter iter = bio->bi_iter;
389         struct nonce nonce = extent_nonce(version, crc_old);
390         struct bch_csum merged = { 0 };
391         struct crc_split {
392                 struct bch_extent_crc_unpacked  *crc;
393                 unsigned                        len;
394                 unsigned                        csum_type;
395                 struct bch_csum                 csum;
396         } splits[3] = {
397                 { crc_a, len_a, new_csum_type },
398                 { crc_b, len_b, new_csum_type },
399                 { NULL,  bio_sectors(bio) - len_a - len_b, new_csum_type },
400         }, *i;
401         bool mergeable = crc_old.csum_type == new_csum_type &&
402                 bch2_checksum_mergeable(new_csum_type);
403         unsigned crc_nonce = crc_old.nonce;
404
405         BUG_ON(len_a + len_b > bio_sectors(bio));
406         BUG_ON(crc_old.uncompressed_size != bio_sectors(bio));
407         BUG_ON(crc_is_compressed(crc_old));
408         BUG_ON(bch2_csum_type_is_encryption(crc_old.csum_type) !=
409                bch2_csum_type_is_encryption(new_csum_type));
410
411         for (i = splits; i < splits + ARRAY_SIZE(splits); i++) {
412                 iter.bi_size = i->len << 9;
413                 if (mergeable || i->crc)
414                         i->csum = __bch2_checksum_bio(c, i->csum_type,
415                                                       nonce, bio, &iter);
416                 else
417                         bio_advance_iter(bio, &iter, i->len << 9);
418                 nonce = nonce_add(nonce, i->len << 9);
419         }
420
421         if (mergeable)
422                 for (i = splits; i < splits + ARRAY_SIZE(splits); i++)
423                         merged = bch2_checksum_merge(new_csum_type, merged,
424                                                      i->csum, i->len << 9);
425         else
426                 merged = bch2_checksum_bio(c, crc_old.csum_type,
427                                 extent_nonce(version, crc_old), bio);
428
429         if (bch2_crc_cmp(merged, crc_old.csum)) {
430                 bch_err(c, "checksum error in bch2_rechecksum_bio() (memory corruption or bug?)\n"
431                         "expected %0llx:%0llx got %0llx:%0llx (old type %s new type %s)",
432                         crc_old.csum.hi,
433                         crc_old.csum.lo,
434                         merged.hi,
435                         merged.lo,
436                         bch2_csum_types[crc_old.csum_type],
437                         bch2_csum_types[new_csum_type]);
438                 return -EIO;
439         }
440
441         for (i = splits; i < splits + ARRAY_SIZE(splits); i++) {
442                 if (i->crc)
443                         *i->crc = (struct bch_extent_crc_unpacked) {
444                                 .csum_type              = i->csum_type,
445                                 .compression_type       = crc_old.compression_type,
446                                 .compressed_size        = i->len,
447                                 .uncompressed_size      = i->len,
448                                 .offset                 = 0,
449                                 .live_size              = i->len,
450                                 .nonce                  = crc_nonce,
451                                 .csum                   = i->csum,
452                         };
453
454                 if (bch2_csum_type_is_encryption(new_csum_type))
455                         crc_nonce += i->len;
456         }
457
458         return 0;
459 }
460
461 #ifdef __KERNEL__
462 static int __bch2_request_key(char *key_description, struct bch_key *key)
463 {
464         struct key *keyring_key;
465         const struct user_key_payload *ukp;
466         int ret;
467
468         keyring_key = request_key(&key_type_user, key_description, NULL);
469         if (IS_ERR(keyring_key))
470                 return PTR_ERR(keyring_key);
471
472         down_read(&keyring_key->sem);
473         ukp = dereference_key_locked(keyring_key);
474         if (ukp->datalen == sizeof(*key)) {
475                 memcpy(key, ukp->data, ukp->datalen);
476                 ret = 0;
477         } else {
478                 ret = -EINVAL;
479         }
480         up_read(&keyring_key->sem);
481         key_put(keyring_key);
482
483         return ret;
484 }
485 #else
486 #include <keyutils.h>
487
488 static int __bch2_request_key(char *key_description, struct bch_key *key)
489 {
490         key_serial_t key_id;
491
492         key_id = request_key("user", key_description, NULL,
493                              KEY_SPEC_USER_KEYRING);
494         if (key_id < 0)
495                 return -errno;
496
497         if (keyctl_read(key_id, (void *) key, sizeof(*key)) != sizeof(*key))
498                 return -1;
499
500         return 0;
501 }
502 #endif
503
504 int bch2_request_key(struct bch_sb *sb, struct bch_key *key)
505 {
506         struct printbuf key_description = PRINTBUF;
507         int ret;
508
509         prt_printf(&key_description, "bcachefs:");
510         pr_uuid(&key_description, sb->user_uuid.b);
511
512         ret = __bch2_request_key(key_description.buf, key);
513         printbuf_exit(&key_description);
514         return ret;
515 }
516
517 int bch2_decrypt_sb_key(struct bch_fs *c,
518                         struct bch_sb_field_crypt *crypt,
519                         struct bch_key *key)
520 {
521         struct bch_encrypted_key sb_key = crypt->key;
522         struct bch_key user_key;
523         int ret = 0;
524
525         /* is key encrypted? */
526         if (!bch2_key_is_encrypted(&sb_key))
527                 goto out;
528
529         ret = bch2_request_key(c->disk_sb.sb, &user_key);
530         if (ret) {
531                 bch_err(c, "error requesting encryption key: %s", bch2_err_str(ret));
532                 goto err;
533         }
534
535         /* decrypt real key: */
536         ret = bch2_chacha_encrypt_key(&user_key, bch2_sb_key_nonce(c),
537                              &sb_key, sizeof(sb_key));
538         if (ret)
539                 goto err;
540
541         if (bch2_key_is_encrypted(&sb_key)) {
542                 bch_err(c, "incorrect encryption key");
543                 ret = -EINVAL;
544                 goto err;
545         }
546 out:
547         *key = sb_key.key;
548 err:
549         memzero_explicit(&sb_key, sizeof(sb_key));
550         memzero_explicit(&user_key, sizeof(user_key));
551         return ret;
552 }
553
554 static int bch2_alloc_ciphers(struct bch_fs *c)
555 {
556         int ret;
557
558         if (!c->chacha20)
559                 c->chacha20 = crypto_alloc_sync_skcipher("chacha20", 0, 0);
560         ret = PTR_ERR_OR_ZERO(c->chacha20);
561
562         if (ret) {
563                 bch_err(c, "error requesting chacha20 module: %s", bch2_err_str(ret));
564                 return ret;
565         }
566
567         if (!c->poly1305)
568                 c->poly1305 = crypto_alloc_shash("poly1305", 0, 0);
569         ret = PTR_ERR_OR_ZERO(c->poly1305);
570
571         if (ret) {
572                 bch_err(c, "error requesting poly1305 module: %s", bch2_err_str(ret));
573                 return ret;
574         }
575
576         return 0;
577 }
578
579 int bch2_disable_encryption(struct bch_fs *c)
580 {
581         struct bch_sb_field_crypt *crypt;
582         struct bch_key key;
583         int ret = -EINVAL;
584
585         mutex_lock(&c->sb_lock);
586
587         crypt = bch2_sb_get_crypt(c->disk_sb.sb);
588         if (!crypt)
589                 goto out;
590
591         /* is key encrypted? */
592         ret = 0;
593         if (bch2_key_is_encrypted(&crypt->key))
594                 goto out;
595
596         ret = bch2_decrypt_sb_key(c, crypt, &key);
597         if (ret)
598                 goto out;
599
600         crypt->key.magic        = BCH_KEY_MAGIC;
601         crypt->key.key          = key;
602
603         SET_BCH_SB_ENCRYPTION_TYPE(c->disk_sb.sb, 0);
604         bch2_write_super(c);
605 out:
606         mutex_unlock(&c->sb_lock);
607
608         return ret;
609 }
610
611 int bch2_enable_encryption(struct bch_fs *c, bool keyed)
612 {
613         struct bch_encrypted_key key;
614         struct bch_key user_key;
615         struct bch_sb_field_crypt *crypt;
616         int ret = -EINVAL;
617
618         mutex_lock(&c->sb_lock);
619
620         /* Do we already have an encryption key? */
621         if (bch2_sb_get_crypt(c->disk_sb.sb))
622                 goto err;
623
624         ret = bch2_alloc_ciphers(c);
625         if (ret)
626                 goto err;
627
628         key.magic = BCH_KEY_MAGIC;
629         get_random_bytes(&key.key, sizeof(key.key));
630
631         if (keyed) {
632                 ret = bch2_request_key(c->disk_sb.sb, &user_key);
633                 if (ret) {
634                         bch_err(c, "error requesting encryption key: %s", bch2_err_str(ret));
635                         goto err;
636                 }
637
638                 ret = bch2_chacha_encrypt_key(&user_key, bch2_sb_key_nonce(c),
639                                               &key, sizeof(key));
640                 if (ret)
641                         goto err;
642         }
643
644         ret = crypto_skcipher_setkey(&c->chacha20->base,
645                         (void *) &key.key, sizeof(key.key));
646         if (ret)
647                 goto err;
648
649         crypt = bch2_sb_resize_crypt(&c->disk_sb, sizeof(*crypt) / sizeof(u64));
650         if (!crypt) {
651                 ret = -BCH_ERR_ENOSPC_sb_crypt;
652                 goto err;
653         }
654
655         crypt->key = key;
656
657         /* write superblock */
658         SET_BCH_SB_ENCRYPTION_TYPE(c->disk_sb.sb, 1);
659         bch2_write_super(c);
660 err:
661         mutex_unlock(&c->sb_lock);
662         memzero_explicit(&user_key, sizeof(user_key));
663         memzero_explicit(&key, sizeof(key));
664         return ret;
665 }
666
667 void bch2_fs_encryption_exit(struct bch_fs *c)
668 {
669         if (!IS_ERR_OR_NULL(c->poly1305))
670                 crypto_free_shash(c->poly1305);
671         if (!IS_ERR_OR_NULL(c->chacha20))
672                 crypto_free_sync_skcipher(c->chacha20);
673         if (!IS_ERR_OR_NULL(c->sha256))
674                 crypto_free_shash(c->sha256);
675 }
676
677 int bch2_fs_encryption_init(struct bch_fs *c)
678 {
679         struct bch_sb_field_crypt *crypt;
680         struct bch_key key;
681         int ret = 0;
682
683         pr_verbose_init(c->opts, "");
684
685         c->sha256 = crypto_alloc_shash("sha256", 0, 0);
686         ret = PTR_ERR_OR_ZERO(c->sha256);
687         if (ret) {
688                 bch_err(c, "error requesting sha256 module: %s", bch2_err_str(ret));
689                 goto out;
690         }
691
692         crypt = bch2_sb_get_crypt(c->disk_sb.sb);
693         if (!crypt)
694                 goto out;
695
696         ret = bch2_alloc_ciphers(c);
697         if (ret)
698                 goto out;
699
700         ret = bch2_decrypt_sb_key(c, crypt, &key);
701         if (ret)
702                 goto out;
703
704         ret = crypto_skcipher_setkey(&c->chacha20->base,
705                         (void *) &key.key, sizeof(key.key));
706         if (ret)
707                 goto out;
708 out:
709         memzero_explicit(&key, sizeof(key));
710         pr_verbose_init(c->opts, "ret %i", ret);
711         return ret;
712 }