[PATCH 2/2] Staging: bcm: Add size maximum size restrictions for IOCTL_IDLE_REQ

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From f228745a844cf56f8d12f06be31a687acd91f653 Mon Sep 17 00:00:00 2001
From: Kevin McKinney <klmckinney1@xxxxxxxxx>
Date: Sat, 3 Sep 2011 15:15:20 -0400
Subject: [PATCH 2/2] Staging: bcm: Add size maximum size restrictions for IOCTL_IDLE_REQ

The maximum size is from the maximum size of the control packet
in ->Adapter->txctlpacket[] which is allocated in InitAdapter().
If we don't cap the max we could get a stack trace from kmalloc()
but it's not harmful.

Signed-off-by: Kevin McKinney <klmckinney1@xxxxxxxxx>
---
 drivers/staging/bcm/Bcmchar.c             |    3 +++
 drivers/staging/bcm/Misc.c                |    4 ++++
 2 files changed, 7 insertions(+), 0 deletions(-)
 delete mode 100644 arch/arm/mach-lpc32xx/include/mach/gpio.h

diff --git a/arch/arm/mach-lpc32xx/include/mach/gpio.h b/arch/arm/mach-lpc32xx/include/mach/gpio.h
deleted file mode 100644
index e69de29..0000000
diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c
index 1905a83..4c43353 100644
--- a/drivers/staging/bcm/Bcmchar.c
+++ b/drivers/staging/bcm/Bcmchar.c
@@ -690,6 +690,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
 		if (IoBuffer.InputLength < sizeof(struct link_request))
 			return -EINVAL;
 
+		if (IoBuffer.InputLength > MAX_CNTL_PKT_SIZE)
+			return -EINVAL;
+
 		pvBuffer = kmalloc(IoBuffer.InputLength, GFP_KERNEL);
 		if (!pvBuffer)
 			return -ENOMEM;
diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c
index c5b3a36..9da9408 100644
--- a/drivers/staging/bcm/Misc.c
+++ b/drivers/staging/bcm/Misc.c
@@ -421,6 +421,10 @@ INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**<Logical Adapter*/
 				pLeader->PLength = pktlen;
 			}
 		}
+
+		if (pktlen + LEADER_SIZE > MAX_CNTL_PKT_SIZE)
+			return -EINVAL;
+
 		memset(ctrl_buff, 0, pktlen+LEADER_SIZE);
 		BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Copying the Control Packet Buffer with length=%d\n", pLeader->PLength);
 		*(PLEADER)ctrl_buff=*pLeader;
-- 
1.7.4.1
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux