On Tue, Sep 25, 2018 at 4:39 PM Dave Jiang <[email protected]> wrote:
>
> Add support for setting and/or updating passphrase on the Intel nvdimms.
> The passphrase is pulled from userspace through the kernel key management.
> We trigger the update via writing "update <old_keyid> <new_keyid>" to the
> sysfs attribute "security". If no <old_keyid> exists (for enabling security)
> then a 0 should be used. The state of the security can also be read via the
> "security" attribute. libnvdimm will generically support the key_change
> API call.
>
> Signed-off-by: Dave Jiang <[email protected]>
[..]
> diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c
> index b7e22e6b80db..e915e6de6c12 100644
> --- a/drivers/nvdimm/dimm_devs.c
> +++ b/drivers/nvdimm/dimm_devs.c
[..]
> +#define SEC_CMD_SIZE 128
> +static ssize_t security_store(struct device *dev,
> +               struct device_attribute *attr, const char *buf, size_t len)
> +
> +{
> +       struct nvdimm *nvdimm = to_nvdimm(dev);
> +       struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
> +       ssize_t rc = -EINVAL;
> +       unsigned int new_key = 0, old_key = 0;
> +       char cmd[SEC_CMD_SIZE];
> +
> +       if (len > SEC_CMD_SIZE)
> +               return -EINVAL;
> +
> +        wait_nvdimm_bus_probe_idle(&nvdimm_bus->dev);
> +        if (atomic_read(&nvdimm->busy))
> +                return -EBUSY;
> +
> +       sscanf(buf, "%s %u %u", cmd, &old_key, &new_key);
> +       if (strcmp(cmd, "update") == 0) {

Please use sysfs_streq() here to catch garbage at the end of the string.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reply via email to