Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1533830

[PATCH 04/10] via-cuda: Prevent read buffer overflow

From Finn Thain <fthain@telegraphics.com.au>
Newsgroups linux.kernel
Subject [PATCH 04/10] via-cuda: Prevent read buffer overflow
Date 2016-12-01 07:10 +0100
Message-ID <sJsJc-8rI-13@gated-at.bofh.it> (permalink)
References <sJsJc-8rI-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


If the Cuda driver does not enter the 'read_done' state for some
reason, it may continue in the 'reading' state until the buffer
overflows. Add a bounds check to prevent this.

Tested-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
---
 drivers/macintosh/via-cuda.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c
index 64626d2..acf3a95 100644
--- a/drivers/macintosh/via-cuda.c
+++ b/drivers/macintosh/via-cuda.c
@@ -470,6 +470,8 @@ cuda_poll(void)
 }
 EXPORT_SYMBOL(cuda_poll);
 
+#define ARRAY_FULL(a, p)	((p) - (a) == ARRAY_SIZE(a))
+
 static irqreturn_t
 cuda_interrupt(int irq, void *arg)
 {
@@ -558,7 +560,11 @@ cuda_interrupt(int irq, void *arg)
 	break;
 
     case reading:
-	*reply_ptr++ = in_8(&via[SR]);
+	if (reading_reply ? ARRAY_FULL(current_req->reply, reply_ptr)
+	                  : ARRAY_FULL(cuda_rbuf, reply_ptr))
+	    (void)in_8(&via[SR]);
+	else
+	    *reply_ptr++ = in_8(&via[SR]);
 	if (!TREQ_asserted(status)) {
 	    /* that's all folks */
 	    negate_TIP_and_TACK();
-- 
2.7.3

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/10] Replace via-maciisi with via-cuda driver Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:10 +0100
  [PATCH 03/10] via-cuda: Add TREQ, TIP and TACK signal helpers Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:10 +0100
  [PATCH 04/10] via-cuda: Prevent read buffer overflow Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:10 +0100
  [PATCH 10/10] m68k/mac: Replace via-maciisi driver with via-cuda  driver Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:10 +0100
  [PATCH 06/10] via-cuda: Avoid TREQ race condition Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:20 +0100
  [PATCH 05/10] via-cuda: Fix re-initialization of reply_ptr and  reading_reply Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:20 +0100
  [PATCH 09/10] via-cuda: Add support for Egret system controller Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:20 +0100
  [PATCH 01/10] via-cuda: Cleanup printk calls Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:20 +0100
  [PATCH 08/10] via-cuda: Initialize data_index early and increment  consistently Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:20 +0100
  [PATCH 02/10] via-cuda: Remove redundant temporary variable Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:20 +0100
  [PATCH 07/10] via-cuda: Use spinlock_irq_save/restore instead of  enable/disable_irq Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:20 +0100

csiph-web