Skip to contentSkip to conversation

sparc64: Properly range check DAX completion index

PATCH In review Rob Gardner 3 participants 4 messages Apr 1, 2018 – Apr 2, 2018 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sparc64: Properly range check DAX completion index

Each Oracle DAX CCB has a corresponding completion area, and the required number of areas must fit within a previously allocated array of completion areas beginning at the requested index. Since the completion area index is specified by a file offset, a user can pass arbitrary values, including negative numbers. So the index must be thoroughly range checked to prevent access to addresses outside the bounds of the allocated completion area array. The index cannot be negative, and it cannot exceed the total array size, less the number of CCBs requested. The old code did not check for negative values and was off by one on the upper bound.

---
 drivers/sbus/char/oradax.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/sbus/char/oradax.c +1 -1
index d8597d5..96b4ad7 100644
@@ -880,7 +880,7 @@ static int dax_ccb_exec(struct dax_ctx *ctx, const char __user *buf,
 	dax_dbg("args: ccb_buf_len=%ld, idx=%d", count, idx);
 
 	/* for given index and length, verify ca_buf range exists */
-	if (idx + nccbs >= DAX_CA_ELEMS) {
+	if (idx < 0 || idx > (DAX_CA_ELEMS - nccbs)) {
 		ctx->result.exec.status = DAX_SUBMIT_ERR_NO_CA_AVAIL;
 		return 0;
 	}
Signature · 1 line
1.7.1
#2 lore raw
In reply to Rob Gardner
Quoted 9 lines · Linus Torvalds
Quoted 3 lines · Rob Gardner

That Reported-by: should be "oguard <[email protected]>"

I was just the messenger.

Linus

oguard observed "lack of size check on the copy_from_user", but that wasn't really a bug since 'count' actually is checked in dax_write().

But you noticed that idx could be negative and idx + nccbs could overflow, and this is a genuine bug that nobody else saw.

Rob

maintainer
#3 lore raw
In reply to Rob Gardner

From: Rob Gardner <[email protected]>
Date: Sun, 1 Apr 2018 12:42:46 -0600

Quoted 10 lines · Linus Torvalds
Quoted 9 lines
Quoted 3 lines · Rob Gardner

That Reported-by: should be "oguard <[email protected]>"

I was just the messenger.

Quoted 8 lines
Quoted 1 line

Linus

oguard observed "lack of size check on the copy_from_user", but that wasn't really a bug since 'count' actually is checked in dax_write().

But you noticed that idx could be negative and idx + nccbs could overflow, and this is a genuine bug that nobody else saw.

Agreed, Linus's as the reporter is correct.

Applied and queued up for -stable, thank you.