Skip to contentSkip to conversation

cxlflash: a couple off by one bugs

PATCH RESEND Applied Matthew R. Ochs 3 participants 3 messages Dec 2, 2015 – Dec 10, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 cxlflash: a couple off by one bugs

From: Dan Carpenter <[email protected]>

The "> MAX_CONTEXT" should be ">= MAX_CONTEXT". Otherwise we go one step beyond the end of the cfg->ctx_tbl[] array.

---
This patch was originally sent by Dan Carpenter in September 2015. I had based my large patch series that went into 4.4 off of it but this patch appears to have not made it in. As a valid fix, I'd like to see this make it into 'next'. I've gone ahead and performed the rebase so that it applies cleanly.

 drivers/scsi/cxlflash/superpipe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/cxlflash/superpipe.c +2 -2
index cac2e6a..34b21a0 100644
@@ -1380,7 +1380,7 @@ static int cxlflash_disk_attach(struct scsi_device *sdev,
 	}
 
 	ctxid = cxl_process_element(ctx);
-	if (unlikely((ctxid > MAX_CONTEXT) || (ctxid < 0))) {
+	if (unlikely((ctxid >= MAX_CONTEXT) || (ctxid < 0))) {
 		dev_err(dev, "%s: ctxid (%d) invalid!\n", __func__, ctxid);
 		rc = -EPERM;
 		goto err2;
@@ -1508,7 +1508,7 @@ static int recover_context(struct cxlflash_cfg *cfg, struct ctx_info *ctxi)
 	}
 
 	ctxid = cxl_process_element(ctx);
-	if (unlikely((ctxid > MAX_CONTEXT) || (ctxid < 0))) {
+	if (unlikely((ctxid >= MAX_CONTEXT) || (ctxid < 0))) {
 		dev_err(dev, "%s: ctxid (%d) invalid!\n", __func__, ctxid);
 		rc = -EPERM;
 		goto err1;
Signature · 1 line
2.1.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 41 lines · Matthew R. Ochs

From: Dan Carpenter <[email protected]>

The "> MAX_CONTEXT" should be ">= MAX_CONTEXT".  Otherwise we go one step beyond the end of the cfg->ctx_tbl[] array.

---
This patch was originally sent by Dan Carpenter in September 2015. I had based my large patch series that went into 4.4 off of it but this patch appears to have not made it in. As a valid fix, I'd like to see this make it into 'next'. I've gone ahead and performed the rebase so that it applies cleanly.

 drivers/scsi/cxlflash/superpipe.c | 4 ++--

 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/cxlflash/superpipe.c +0 -0
index cac2e6a..34b21a0 100644
@@ -1380,7 +1380,7 @@ static int cxlflash_disk_attach(struct scsi_device
 *sdev,
  	}


  ctxid = cxl_process_element(ctx);

drivers/scsi/cxlflash/superpipe.c +1 -1
-	if (unlikely((ctxid > MAX_CONTEXT) || (ctxid < 0))) {
+	if (unlikely((ctxid >= MAX_CONTEXT) || (ctxid < 0))) {

  dev_err(dev, "%s: ctxid (%d) invalid!\n", __func__, ctxid); rc = -EPERM;
  goto err2;

drivers/scsi/cxlflash/superpipe.c +0 -0
@@ -1508,7 +1508,7 @@ static int recover_context(struct cxlflash_cfg *cfg,
 struct ctx_info *ctxi)
  	}


  ctxid = cxl_process_element(ctx);

drivers/scsi/cxlflash/superpipe.c +1 -1
-	if (unlikely((ctxid > MAX_CONTEXT) || (ctxid < 0))) {
+	if (unlikely((ctxid >= MAX_CONTEXT) || (ctxid < 0))) {
Quoted 3 lines

  dev_err(dev, "%s: ctxid (%d) invalid!\n", __func__, ctxid); rc = -EPERM;
  goto err1;

#2 lore raw
In reply to Matthew R. Ochs
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Matthew" = Matthew R Ochs <[email protected]> writes:

Matthew> The "> MAX_CONTEXT" should be ">= MAX_CONTEXT". Otherwise we Matthew> go one step beyond the end of the cfg->ctx_tbl[] array.

Applied to 4.5/scsi-queue.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering