All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Elliott, Robert (Persistent Memory)" <elliott@hpe.com>
To: 'Dave Jiang' <dave.jiang@intel.com>,
	"dan.j.williams@intel.com" <dan.j.williams@intel.com>
Cc: "linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>
Subject: RE: [PATCH v15 07/16] acpi/nfit, libnvdimm: Add unlock of nvdimm support for Intel DIMMs
Date: Tue, 15 Jan 2019 21:56:33 +0000	[thread overview]
Message-ID: <AT5PR8401MB11696C3B8B5A7E5E92608125AB810@AT5PR8401MB1169.NAMPRD84.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <154474491540.64529.6730683963766405362.stgit@djiang5-desk3.ch.intel.com>



> -----Original Message-----
> From: Linux-nvdimm [mailto:linux-nvdimm-bounces@lists.01.org] On Behalf Of Dave Jiang
> Sent: Thursday, December 13, 2018 5:49 PM
> To: dan.j.williams@intel.com
> Cc: linux-nvdimm@lists.01.org
> Subject: [PATCH v15 07/16] acpi/nfit, libnvdimm: Add unlock of nvdimm support for Intel DIMMs
> 
> From: Dan Williams <dan.j.williams@intel.com>
> 
...
> +static int __nvdimm_security_unlock(struct nvdimm *nvdimm)
> +{
> +	struct device *dev = &nvdimm->dev;
> +	struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
> +	struct key *key = NULL;
> +	int rc;
> +
> +	/* The bus lock should be held at the top level of the call stack */
> +	lockdep_assert_held(&nvdimm_bus->reconfig_mutex);
> +
> +	if (!nvdimm->sec.ops || !nvdimm->sec.ops->unlock
> +			|| nvdimm->sec.state < 0)
> +		return -EIO;
> +
> +	/*
> +	 * If the pre-OS has unlocked the DIMM, attempt to send the key
> +	 * from request_key() to the hardware for verification.  Failure
> +	 * to revalidate the key against the hardware results in a
> +	 * freeze of the security configuration. I.e. if the OS does not
> +	 * have the key, security is being managed pre-OS.
> +	 */
> +	if (nvdimm->sec.state == NVDIMM_SECURITY_UNLOCKED) {
> +		if (!key_revalidate)
> +			return 0;
> +
> +		key = nvdimm_key_revalidate(nvdimm);
> +		if (!key)
> +			return nvdimm_security_freeze(nvdimm);

If it's already unlocked, regardless of whether nvdimm_key_revalidate()
succeeds or fails, I'm not sure you should call nvdimm_security_freeze().  

The kernel doesn't know the key, so a hands-off policy seems prudent -
don't send any commands that change the security state.  Some other
software (pre-OS or application) must be handling the feature, and
sending freeze lock might interfere with that software.

Maybe you intended that to be "if (key)", intending to freeze if the
kernel does have the correct key (so no application can change it and
render the kernel out of sync)?


> +	} else
> +		key = nvdimm_request_key(nvdimm);
> +
> +	if (!key)
> +		return -ENOKEY;
> +
> +	rc = nvdimm->sec.ops->unlock(nvdimm, key_data(key));
> +	dev_dbg(dev, "key: %d unlock: %s\n", key_serial(key),
> +			rc == 0 ? "success" : "fail");
> +
> +	nvdimm_put_key(key);
> +	nvdimm->sec.state = nvdimm_security_state(nvdimm);
> +	return rc;
> +}
> +

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

  reply	other threads:[~2019-01-15 21:58 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-13 23:47 [PATCH v15 00/16] Adding security support for nvdimm Dave Jiang
2018-12-13 23:48 ` [PATCH v15 01/16] acpi/nfit: Add support for Intel DSM 1.8 commands Dave Jiang
2018-12-14  1:57   ` Dan Williams
2018-12-13 23:48 ` [PATCH v15 02/16] acpi/nfit, libnvdimm: Store dimm id as a member to struct nvdimm Dave Jiang
2018-12-13 23:48 ` [PATCH v15 03/16] keys: Export lookup_user_key to external users Dave Jiang
2018-12-13 23:48 ` [PATCH v15 04/16] keys-encrypted: add nvdimm key format type to encrypted keys Dave Jiang
2018-12-13 23:48 ` [PATCH v15 05/16] acpi/nfit, libnvdimm: Introduce nvdimm_security_ops Dave Jiang
2018-12-13 23:48 ` [PATCH v15 06/16] acpi/nfit, libnvdimm: Add freeze security support to Intel nvdimm Dave Jiang
2018-12-13 23:48 ` [PATCH v15 07/16] acpi/nfit, libnvdimm: Add unlock of nvdimm support for Intel DIMMs Dave Jiang
2019-01-15 21:56   ` Elliott, Robert (Persistent Memory) [this message]
2019-01-15 22:35     ` Dave Jiang
2018-12-13 23:48 ` [PATCH v15 08/16] acpi/nfit, libnvdimm: Add disable passphrase support to Intel nvdimm Dave Jiang
2018-12-13 23:48 ` [PATCH v15 09/16] acpi/nfit, libnvdimm: Add enable/update passphrase support for Intel nvdimms Dave Jiang
2018-12-13 23:48 ` [PATCH v15 10/16] acpi/nfit, libnvdimm: Add support for issue secure erase DSM to Intel nvdimm Dave Jiang
2018-12-13 23:48 ` [PATCH v15 11/16] acpi/nfit, libnvdimm/security: Add security DSM overwrite support Dave Jiang
2018-12-13 23:49 ` [PATCH v15 12/16] acpi/nfit, libnvdimm/security: add Intel DSM 1.8 master passphrase support Dave Jiang
2018-12-13 23:49 ` [PATCH v15 13/16] tools/testing/nvdimm: Add test support for Intel nvdimm security DSMs Dave Jiang
2018-12-13 23:49 ` [PATCH v15 14/16] tools/testing/nvdimm: Add overwrite support for nfit_test Dave Jiang
2018-12-13 23:49 ` [PATCH v15 15/16] tools/testing/nvdimm: add Intel DSM 1.8 " Dave Jiang
2018-12-13 23:49 ` [PATCH v15 16/16] libnvdimm/security: Add documentation for nvdimm security support Dave Jiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AT5PR8401MB11696C3B8B5A7E5E92608125AB810@AT5PR8401MB1169.NAMPRD84.PROD.OUTLOOK.COM \
    --to=elliott@hpe.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.