Skip to contentSkip to conversation

udmabuf: fix general protection fault in udmabuf_create

PATCH Applied Pavel Skripkin 2 participants 2 messages Aug 11, 2021 – Aug 12, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 udmabuf: fix general protection fault in udmabuf_create

Syzbot reported general protection fault in udmabuf_create. The problem was in wrong error handling.

In commit 16c243e99d33 ("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 [email protected]
Fixes 16c243e99d33 ("udmabuf: Add support for mapping hugepages (v4)")
---
 drivers/dma-buf/udmabuf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma-buf/udmabuf.c +2 -2
index 8df761a10251..c57a609db75b 100644
@@ -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;
 					}
 				}
Signature · 1 line
2.32.0
maintainer Applied
#1 lore raw
Quoted 7 lines · Pavel Skripkin

Syzbot reported general protection fault in udmabuf_create. The problem was in wrong error handling.

In commit 16c243e99d33 ("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().

Quoted 6 lines

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 [email protected]
Fixes 16c243e99d33 ("udmabuf: Add support for mapping hugepages (v4)")

Pushed to drm-misc-next.

thanks,
Gerd