Skip to content

Commit 5069515

Browse files
committed
drivers/rapidio/rio_cm.c: prevent possible heap overwrite
In riocm_cdev_ioctl(RIO_CM_CHAN_SEND) -> cm_chan_msg_send() -> riocm_ch_send() cm_chan_msg_send() checks that userspace didn't send too much data but riocm_ch_send() failed to check that userspace sent sufficient data. The result is that riocm_ch_send() can write to fields in the rio_ch_chan_hdr which were outside the bounds of the space which cm_chan_msg_send() allocated. Address this by teaching riocm_ch_send() to check that the entire rio_ch_chan_hdr was copied in from userspace. Reported-by: maher azz <[email protected]> Cc: Matt Porter <[email protected]> Cc: Alexandre Bounine <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 383c461 commit 5069515

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/rapidio/rio_cm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,9 @@ static int riocm_ch_send(u16 ch_id, void *buf, int len)
783783
if (buf == NULL || ch_id == 0 || len == 0 || len > RIO_MAX_MSG_SIZE)
784784
return -EINVAL;
785785

786+
if (len < sizeof(struct rio_ch_chan_hdr))
787+
return -EINVAL; /* insufficient data from user */
788+
786789
ch = riocm_get_channel(ch_id);
787790
if (!ch) {
788791
riocm_error("%s(%d) ch_%d not found", current->comm,

0 commit comments

Comments
 (0)