Commit e228b742 authored by Kevin McKinney's avatar Kevin McKinney Committed by Greg Kroah-Hartman

Staging: bcm: Add size maximum size restrictions for IOCTL_IDLE_REQ

In the first alteration, the MAX_CNTL_PKT_SIZE is the
maximum size of the control packet in ->Adapter->txctlpacket[]
which is defined in InitAdapter(). This caps the size of
kmalloc memory allocation. In the second change, this max
cap fixes a potential memory corruption bug when subsequent
memset and memcpy calls are invoked.
Signed-off-by: default avatarKevin McKinney <klmckinney1@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 5ac5bd87
...@@ -690,6 +690,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) ...@@ -690,6 +690,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
if (IoBuffer.InputLength < sizeof(struct link_request)) if (IoBuffer.InputLength < sizeof(struct link_request))
return -EINVAL; return -EINVAL;
if (IoBuffer.InputLength > MAX_CNTL_PKT_SIZE)
return -EINVAL;
pvBuffer = kmalloc(IoBuffer.InputLength, GFP_KERNEL); pvBuffer = kmalloc(IoBuffer.InputLength, GFP_KERNEL);
if (!pvBuffer) if (!pvBuffer)
return -ENOMEM; return -ENOMEM;
......
...@@ -421,6 +421,10 @@ INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**<Logical Adapter*/ ...@@ -421,6 +421,10 @@ INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**<Logical Adapter*/
pLeader->PLength = pktlen; pLeader->PLength = pktlen;
} }
} }
if (pktlen + LEADER_SIZE > MAX_CNTL_PKT_SIZE)
return -EINVAL;
memset(ctrl_buff, 0, pktlen+LEADER_SIZE); 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); 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; *(PLEADER)ctrl_buff=*pLeader;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment