···44 select LIBCRC32C55 select CRYPTO_AES66 select CRYPTO77+ select KEYS78 default n89 help910 Choose Y or M here to include cephlib, which provides the
+58
net/ceph/ceph_common.c
···55#include <linux/fs.h>66#include <linux/inet.h>77#include <linux/in6.h>88+#include <linux/key.h>99+#include <keys/user-type.h>810#include <linux/module.h>911#include <linux/mount.h>1012#include <linux/parser.h>···199197 Opt_fsid,200198 Opt_name,201199 Opt_secret,200200+ Opt_key,202201 Opt_ip,203202 Opt_last_string,204203 /* string args above */···216213 {Opt_fsid, "fsid=%s"},217214 {Opt_name, "name=%s"},218215 {Opt_secret, "secret=%s"},216216+ {Opt_key, "key=%s"},219217 {Opt_ip, "ip=%s"},220218 /* string args above */221219 {Opt_noshare, "noshare"},···235231 kfree(opt);236232}237233EXPORT_SYMBOL(ceph_destroy_options);234234+235235+/* get secret from key store */236236+static int get_secret(struct ceph_crypto_key *dst, const char *name) {237237+ struct key *ukey;238238+ int key_err;239239+ int err = 0;240240+ struct user_key_payload *payload;241241+ void *p;242242+243243+ ukey = request_key(&key_type_user, name, NULL);244244+ if (!ukey || IS_ERR(ukey)) {245245+ /* request_key errors don't map nicely to mount(2)246246+ errors; don't even try, but still printk */247247+ key_err = PTR_ERR(ukey);248248+ switch (key_err) {249249+ case -ENOKEY:250250+ pr_warning("ceph: Mount failed due to key not found: %s\n", name);251251+ break;252252+ case -EKEYEXPIRED:253253+ pr_warning("ceph: Mount failed due to expired key: %s\n", name);254254+ break;255255+ case -EKEYREVOKED:256256+ pr_warning("ceph: Mount failed due to revoked key: %s\n", name);257257+ break;258258+ default:259259+ pr_warning("ceph: Mount failed due to unknown key error"260260+ " %d: %s\n", key_err, name);261261+ }262262+ err = -EPERM;263263+ goto out;264264+ }265265+266266+ payload = ukey->payload.data;267267+ p = payload->data;268268+ err = ceph_crypto_key_decode(dst, &p, p + payload->datalen);269269+ if (err)270270+ goto out_key;271271+ /* pass through, err is 0 */272272+273273+out_key:274274+ key_put(ukey);275275+out:276276+ return err;277277+}238278239279int ceph_parse_options(struct ceph_options **popt, char *options,240280 const char *dev_name, const char *dev_name_end,···373325 goto out;374326 }375327 err = ceph_crypto_key_unarmor(opt->key, argstr[0].from);328328+ if (err < 0)329329+ goto out;330330+ break;331331+ case Opt_key:332332+ opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL);333333+ if (!opt->key) {334334+ err = -ENOMEM;335335+ goto out;336336+ }337337+ err = get_secret(opt->key, argstr[0].from);376338 if (err < 0)377339 goto out;378340 break;