> -----Original Message----- > From: Linux-nvdimm [mailto:[email protected]] On Behalf Of > Dave Jiang > Sent: Monday, July 2, 2018 6:39 PM > To: [email protected] > Cc: [email protected]; [email protected]; > [email protected]; [email protected]; > [email protected] > Subject: [PATCH 04/11] nfit/libnvdimm: add unlock of nvdimm support for Intel > DIMMs > > Adding support to allow query the security status of the Intel nvdimms and > also unlock the dimm via the kernel key management APIs. The passphrase is > expected to be pulled from userspace through keyutils. Moving the Intel > related bits to its own source file as well. > ... > +static int intel_dimm_security_unlock(struct nvdimm_bus *nvdimm_bus, > + struct nvdimm *nvdimm, const char *passphrase) > +{ + struct nd_intel_unlock_unit *cmd; + struct nd_cmd_pkg *pkg; ... > + pkg_size = sizeof(*pkg) + sizeof(*cmd); > + pkg = kzalloc(pkg_size, GFP_KERNEL); > + if (!pkg) > + return -ENOMEM; > + > + pkg->nd_command = NVDIMM_INTEL_UNLOCK_UNIT; > + pkg->nd_family = NVDIMM_FAMILY_INTEL; > + pkg->nd_size_in = ND_INTEL_PASSPHRASE_SIZE; > + pkg->nd_size_out = ND_INTEL_STATUS_SIZE; > + pkg->nd_fw_size = ND_INTEL_STATUS_SIZE; > + cmd = (struct nd_intel_unlock_unit *)&pkg->nd_payload; > + memcpy(cmd->passphrase, passphrase, ND_INTEL_PASSPHRASE_SIZE); > + rc = nd_desc->ndctl(nd_desc, nvdimm, ND_CMD_CALL, pkg, > + sizeof(pkg_size), &cmd_rc); ... > + kfree(pkg); Since it contains a high-value password, I recommend zeroing cmd->passphrase before calling kfree() so that data isn't seen by a subsequent kmalloc() caller (and make sure the compiler cannot optimize away the clearing code). clear) Also, check if the ndctl() call chain makes any copies of cmd->passphrase and ensure they are cleared. --- Robert Elliott, HPE Persistent Memory _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
RE: [PATCH 04/11] nfit/libnvdimm: add unlock of nvdimm support for Intel DIMMs
Elliott, Robert (Persistent Memory) Mon, 02 Jul 2018 18:46:33 -0700
- Re: [PATCH 02/11] libnvdimm: crea... Dan Williams
- [PATCH 07/11] nfit/libnvdimm: add free... Dave Jiang
- [PATCH 05/11] nfit/libnvdimm: add set ... Dave Jiang
- Re: [PATCH 05/11] nfit/libnvdimm:... Dan Williams
- [PATCH 09/11] nfit_test: adding contex... Dave Jiang
- [PATCH 06/11] nfit/libnvdimm: add disa... Dave Jiang
- [PATCH 08/11] nfit/libnvdimm: add supp... Dave Jiang
- [PATCH 11/11] libnvdimm: adding docume... Dave Jiang
- [PATCH 10/11] nfit_test: adding test s... Dave Jiang
- [PATCH 04/11] nfit/libnvdimm: add unlo... Dave Jiang
- RE: [PATCH 04/11] nfit/libnvdimm:... Elliott, Robert (Persistent Memory)
- Re: [PATCH 04/11] nfit/libnvd... Dan Williams
- RE: [PATCH 04/11] nfit/li... Elliott, Robert (Persistent Memory)
- Re: [PATCH 04/11] nfi... Dan Williams
- Re: [PATCH 04/11] nfit/li... James Morris
- Re: [PATCH 04/11] nfi... Dan Williams
- Re: [PATCH 04/11] nfit/libnvdimm:... Dan Williams
