Message ID | 167030054822.4044561.4917796262037689553.stgit@dwillia2-xfh.jf.intel.com |
---|---|
State | Accepted |
Commit | f5ee4cc19c3eff4459931b6fe8f29d1e0cc204a5 |
Headers | show |
Series | cxl/mbox: Output payload validation reworks | expand |
On Mon, Dec 05, 2022 at 08:22:28PM -0800, Dan Williams wrote: > Multi-byte integer values in CXL mailbox payloads are little endian. Add > a definition of the Get Security State output payload and convert the > value before testing flags. > > Fixes: 328281155539 ("cxl/pmem: Introduce nvdimm_security_ops with ->get_flags() operation") > Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com> > Cc: Dave Jiang <dave.jiang@intel.com> > Signed-off-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> > --- > drivers/cxl/security.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/cxl/security.c b/drivers/cxl/security.c > index 5484d4eecfd1..ebb78b8944f5 100644 > --- a/drivers/cxl/security.c > +++ b/drivers/cxl/security.c > @@ -16,14 +16,18 @@ static unsigned long cxl_pmem_get_security_flags(struct nvdimm *nvdimm, > struct cxl_memdev *cxlmd = cxl_nvd->cxlmd; > struct cxl_dev_state *cxlds = cxlmd->cxlds; > unsigned long security_flags = 0; > + struct cxl_get_security_output { > + __le32 flags; > + } out; > u32 sec_out; > int rc; > > rc = cxl_mbox_send_cmd(cxlds, CXL_MBOX_OP_GET_SECURITY_STATE, NULL, 0, > - &sec_out, sizeof(sec_out)); > + &out, sizeof(out)); > if (rc < 0) > return 0; > > + sec_out = le32_to_cpu(out.flags); > if (ptype == NVDIMM_MASTER) { > if (sec_out & CXL_PMEM_SEC_STATE_MASTER_PASS_SET) > set_bit(NVDIMM_SECURITY_UNLOCKED, &security_flags); >
On 12/5/2022 9:22 PM, Dan Williams wrote: > Multi-byte integer values in CXL mailbox payloads are little endian. Add > a definition of the Get Security State output payload and convert the > value before testing flags. > > Fixes: 328281155539 ("cxl/pmem: Introduce nvdimm_security_ops with ->get_flags() operation") > Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com> > Cc: Dave Jiang <dave.jiang@intel.com> > Signed-off-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Looks like I missed the endian conversion. Thanks! > --- > drivers/cxl/security.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/cxl/security.c b/drivers/cxl/security.c > index 5484d4eecfd1..ebb78b8944f5 100644 > --- a/drivers/cxl/security.c > +++ b/drivers/cxl/security.c > @@ -16,14 +16,18 @@ static unsigned long cxl_pmem_get_security_flags(struct nvdimm *nvdimm, > struct cxl_memdev *cxlmd = cxl_nvd->cxlmd; > struct cxl_dev_state *cxlds = cxlmd->cxlds; > unsigned long security_flags = 0; > + struct cxl_get_security_output { > + __le32 flags; > + } out; > u32 sec_out; > int rc; > > rc = cxl_mbox_send_cmd(cxlds, CXL_MBOX_OP_GET_SECURITY_STATE, NULL, 0, > - &sec_out, sizeof(sec_out)); > + &out, sizeof(out)); > if (rc < 0) > return 0; > > + sec_out = le32_to_cpu(out.flags); > if (ptype == NVDIMM_MASTER) { > if (sec_out & CXL_PMEM_SEC_STATE_MASTER_PASS_SET) > set_bit(NVDIMM_SECURITY_UNLOCKED, &security_flags); >
On Mon, 05 Dec 2022 20:22:28 -0800 Dan Williams <dan.j.williams@intel.com> wrote: > Multi-byte integer values in CXL mailbox payloads are little endian. Add > a definition of the Get Security State output payload and convert the > value before testing flags. > > Fixes: 328281155539 ("cxl/pmem: Introduce nvdimm_security_ops with ->get_flags() operation") > Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com> > Cc: Dave Jiang <dave.jiang@intel.com> > Signed-off-by: Dan Williams <dan.j.williams@intel.com> Ah. Missed this one. Good catch. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> > --- > drivers/cxl/security.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/cxl/security.c b/drivers/cxl/security.c > index 5484d4eecfd1..ebb78b8944f5 100644 > --- a/drivers/cxl/security.c > +++ b/drivers/cxl/security.c > @@ -16,14 +16,18 @@ static unsigned long cxl_pmem_get_security_flags(struct nvdimm *nvdimm, > struct cxl_memdev *cxlmd = cxl_nvd->cxlmd; > struct cxl_dev_state *cxlds = cxlmd->cxlds; > unsigned long security_flags = 0; > + struct cxl_get_security_output { > + __le32 flags; > + } out; > u32 sec_out; > int rc; > > rc = cxl_mbox_send_cmd(cxlds, CXL_MBOX_OP_GET_SECURITY_STATE, NULL, 0, > - &sec_out, sizeof(sec_out)); > + &out, sizeof(out)); > if (rc < 0) > return 0; > > + sec_out = le32_to_cpu(out.flags); > if (ptype == NVDIMM_MASTER) { > if (sec_out & CXL_PMEM_SEC_STATE_MASTER_PASS_SET) > set_bit(NVDIMM_SECURITY_UNLOCKED, &security_flags); >
diff --git a/drivers/cxl/security.c b/drivers/cxl/security.c index 5484d4eecfd1..ebb78b8944f5 100644 --- a/drivers/cxl/security.c +++ b/drivers/cxl/security.c @@ -16,14 +16,18 @@ static unsigned long cxl_pmem_get_security_flags(struct nvdimm *nvdimm, struct cxl_memdev *cxlmd = cxl_nvd->cxlmd; struct cxl_dev_state *cxlds = cxlmd->cxlds; unsigned long security_flags = 0; + struct cxl_get_security_output { + __le32 flags; + } out; u32 sec_out; int rc; rc = cxl_mbox_send_cmd(cxlds, CXL_MBOX_OP_GET_SECURITY_STATE, NULL, 0, - &sec_out, sizeof(sec_out)); + &out, sizeof(out)); if (rc < 0) return 0; + sec_out = le32_to_cpu(out.flags); if (ptype == NVDIMM_MASTER) { if (sec_out & CXL_PMEM_SEC_STATE_MASTER_PASS_SET) set_bit(NVDIMM_SECURITY_UNLOCKED, &security_flags);
Multi-byte integer values in CXL mailbox payloads are little endian. Add a definition of the Get Security State output payload and convert the value before testing flags. Fixes: 328281155539 ("cxl/pmem: Introduce nvdimm_security_ops with ->get_flags() operation") Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- drivers/cxl/security.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)