History

drivers/virt/fsl_hypervisor.c: prevent integer overflow in ioctl

The "param.count" value is a u64 thatcomes from the user. The code later in the function assumes that param.count is at least one and if it's not then it leads to an Oops when we dereference the ZERO_SIZE_PTR. Also the addition can have an integer overflow which would lead us to allocate a smaller "pages" array than required. I can't immediately tell what the possible run times implications are, but it's safest to prevent the overflow.

Dan Carpenter committed 7 years ago

Commit 6a024331 parent c8ea3661 file · +3 −0Browse files

Unified · Split

drivers/virt/fsl_hypervisor.c+3−0
@@ -215,6 +215,9 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p) · 214 unmodified lines
215215 * hypervisor.
216216 */
217217 lb_offset = param.local_vaddr & (PAGE_SIZE - 1);
218+ if (param.count == 0 ||
219+ param.count > U64_MAX - lb_offset - PAGE_SIZE + 1)
220+ return -EINVAL;
218221 num_pages = (param.count + lb_offset + PAGE_SIZE - 1) >> PAGE_SHIFT;
219222
220223 /* Allocate the buffers we need */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t