提交 fe73b582 编写于 作者: F Finn Thain 提交者: Michael Ellerman

via-cuda: Prevent read buffer overflow

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: NStan Johnson <userm57@yahoo.com>
Signed-off-by: NFinn Thain <fthain@telegraphics.com.au>
Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
上级 fd7a65a2
......@@ -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();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册