]> git.baikalelectronics.ru Git - kernel.git/commit
udmabuf: validate ubuf->pagecount
authorPavel Skripkin <paskripkin@gmail.com>
Thu, 30 Dec 2021 14:26:49 +0000 (17:26 +0300)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 18 Jan 2022 06:52:41 +0000 (07:52 +0100)
commit0efefe88ec4c62e57477dd09854e13d8579e4ee6
treeddd26905a18679cd5860f0b3e1ad926348c7e52e
parent0f60fa0c547f4aa485dc01eb4ac65bdd6dd07c1d
udmabuf: validate ubuf->pagecount

Syzbot has reported GPF in sg_alloc_append_table_from_pages(). The
problem was in ubuf->pages == ZERO_PTR.

ubuf->pagecount is calculated from arguments passed from user-space. If
user creates udmabuf with list.size == 0 then ubuf->pagecount will be
also equal to zero; it causes kmalloc_array() to return ZERO_PTR.

Fix it by validating ubuf->pagecount before passing it to
kmalloc_array().

Fixes: 3ab4f832b0ba ("Add udmabuf misc device")
Reported-and-tested-by: syzbot+2c56b725ec547fa9cb29@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20211230142649.23022-1-paskripkin@gmail.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
drivers/dma-buf/udmabuf.c