lkml.org 
[lkml]   [2019]   [Mar]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH 3/6] libnvdimm/security: Drop direct dependency on key_type_encrypted
    From
    Date


    On 3/18/19 11:06 PM, Dan Williams wrote:
    > Lookup the key type by name and protect libnvdimm from encrypted_keys.ko
    > module load failures.
    >
    > Cc: Vishal Verma <vishal.l.verma@intel.com>
    > Cc: Dave Jiang <dave.jiang@intel.com>
    > Cc: Keith Busch <keith.busch@intel.com>
    > Cc: Ira Weiny <ira.weiny@intel.com>
    > Signed-off-by: Dan Williams <dan.j.williams@intel.com>

    Reviewed-by: Dave Jiang <dave.jiang@intel.com>

    > ---
    > drivers/nvdimm/security.c | 11 +++++++++--
    > 1 file changed, 9 insertions(+), 2 deletions(-)
    >
    > diff --git a/drivers/nvdimm/security.c b/drivers/nvdimm/security.c
    > index f8bb746a549f..7f9e412f743a 100644
    > --- a/drivers/nvdimm/security.c
    > +++ b/drivers/nvdimm/security.c
    > @@ -48,12 +48,17 @@ static void nvdimm_put_key(struct key *key)
    > static struct key *nvdimm_request_key(struct nvdimm *nvdimm)
    > {
    > struct key *key = NULL;
    > + struct key_type *type;
    > static const char NVDIMM_PREFIX[] = "nvdimm:";
    > char desc[NVDIMM_KEY_DESC_LEN + sizeof(NVDIMM_PREFIX)];
    > struct device *dev = &nvdimm->dev;
    >
    > sprintf(desc, "%s%s", NVDIMM_PREFIX, nvdimm->dimm_id);
    > - key = request_key(&key_type_encrypted, desc, "");
    > + type = key_type_lookup("encrypted");
    > + if (IS_ERR(type))
    > + return (struct key *) type;
    > +
    > + key = request_key(type, desc, "");
    > if (IS_ERR(key)) {
    > if (PTR_ERR(key) == -ENOKEY)
    > dev_dbg(dev, "request_key() found no key\n");
    > @@ -88,7 +93,7 @@ static struct key *nvdimm_lookup_user_key(struct nvdimm *nvdimm,
    > return NULL;
    >
    > key = key_ref_to_ptr(keyref);
    > - if (key->type != &key_type_encrypted) {
    > + if (strcmp(key->type->name, "encrypted") != 0) {
    > key_put(key);
    > return NULL;
    > }
    > @@ -452,3 +457,5 @@ void nvdimm_security_overwrite_query(struct work_struct *work)
    > __nvdimm_security_overwrite_query(nvdimm);
    > nvdimm_bus_unlock(&nvdimm->dev);
    > }
    > +
    > +MODULE_SOFTDEP("pre: encrypted_keys");
    >

    \
     
     \ /
      Last update: 2019-03-19 17:46    [W:4.109 / U:0.060 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site