summaryrefslogtreecommitdiff
path: root/drivers/sbus/char
diff options
context:
space:
mode:
authorRob Gardner <rob.gardner@oracle.com>2018-03-31 22:53:01 -0600
committerDavid S. Miller <davem@davemloft.net>2018-04-01 20:07:00 -0400
commit49d7006d9f01d435661d03bbea3db4c33935b3d8 (patch)
treeb1581392bb2519b4034eb54eecf398fd6eb55ac6 /drivers/sbus/char
parenta68277b786347b0d3acc3976f693c5065a296fba (diff)
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. Signed-off-by: Rob Gardner <rob.gardner@oracle.com> Signed-off-by: Jonathan Helman <jonathan.helman@oracle.com> Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/sbus/char')
-rw-r--r--drivers/sbus/char/oradax.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/sbus/char/oradax.c b/drivers/sbus/char/oradax.c
index 03dc04739225..c44d7c7ffc92 100644
--- a/drivers/sbus/char/oradax.c
+++ b/drivers/sbus/char/oradax.c
@@ -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;
}