Skip to content

Commit dfd8ee9

Browse files
xiwgregkh
authored andcommitted
Staging: comedi: fix integer overflow in do_insnlist_ioctl()
There is a potential integer overflow in do_insnlist_ioctl() if userspace passes in a large insnlist.n_insns. The call to kmalloc() would allocate a small buffer, leading to a memory corruption. The bug was reported by Dan Carpenter <dan.carpenter@oracle.com> and Haogang Chen <haogangchen@gmail.com>. The patch was suggested by Ian Abbott <abbotti@mev.co.uk> and Lars-Peter Clausen <lars@metafoo.de>. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Reported-by: Haogang Chen <haogangchen@gmail.com>. Cc: Ian Abbott <abbotti@mev.co.uk> Cc: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Xi Wang <xi.wang@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 06b446c commit dfd8ee9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎drivers/staging/comedi/comedi_fops.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ static int do_insnlist_ioctl(struct comedi_device *dev,
671671
}
672672

673673
insns =
674-
kmalloc(sizeof(struct comedi_insn) * insnlist.n_insns, GFP_KERNEL);
674+
kcalloc(insnlist.n_insns, sizeof(struct comedi_insn), GFP_KERNEL);
675675
if (!insns) {
676676
DPRINTK("kmalloc failed\n");
677677
ret = -ENOMEM;

0 commit comments

Comments
 (0)