Skip to content

Commit

Permalink
udmabuf: fix general protection fault in udmabuf_create
Browse files Browse the repository at this point in the history
Syzbot reported general protection fault in udmabuf_create. The problem
was in wrong error handling.

In commit 16c243e ("udmabuf: Add support for mapping hugepages (v4)")
shmem_read_mapping_page() call was replaced with find_get_page_flags(),
but find_get_page_flags() returns NULL on failure instead PTR_ERR().

Wrong error checking was causing GPF in get_page(), since passed page
was equal to NULL. Fix it by changing if (IS_ER(!hpage)) to if (!hpage)

Reported-by: syzbot+e9cd3122a37c5d6c51e8@syzkaller.appspotmail.com
Fixes: 16c243e ("udmabuf: Add support for mapping hugepages (v4)")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20210811175052.21254-1-paskripkin@gmail.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
  • Loading branch information
Pavel Skripkin authored and Gerd Hoffmann committed Aug 12, 2021
1 parent 83326a7 commit b9770b0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/dma-buf/udmabuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ static long udmabuf_create(struct miscdevice *device,
if (!hpage) {
hpage = find_get_page_flags(mapping, pgoff,
FGP_ACCESSED);
if (IS_ERR(hpage)) {
ret = PTR_ERR(hpage);
if (!hpage) {
ret = -EINVAL;
goto err;
}
}
Expand Down

0 comments on commit b9770b0

Please sign in to comment.