linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH next] udmabuf: fix general protection fault in udmabuf_create
@ 2021-08-11 17:50 Pavel Skripkin
  2021-08-12  7:32 ` Gerd Hoffmann
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Skripkin @ 2021-08-11 17:50 UTC (permalink / raw)
  To: kraxel, sumit.semwal, christian.koenig, dongwon.kim
  Cc: linux-media, linaro-mm-sig, linux-kernel, Pavel Skripkin,
	syzbot+e9cd3122a37c5d6c51e8

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: syzbot+e9cd3122a37c5d6c51e8@syzkaller.appspotmail.com
Fixes: 16c243e99d33 ("udmabuf: Add support for mapping hugepages (v4)")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
 drivers/dma-buf/udmabuf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c
index 8df761a10251..c57a609db75b 100644
--- a/drivers/dma-buf/udmabuf.c
+++ b/drivers/dma-buf/udmabuf.c
@@ -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;
 					}
 				}
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH next] udmabuf: fix general protection fault in udmabuf_create
  2021-08-11 17:50 [PATCH next] udmabuf: fix general protection fault in udmabuf_create Pavel Skripkin
@ 2021-08-12  7:32 ` Gerd Hoffmann
  0 siblings, 0 replies; 2+ messages in thread
From: Gerd Hoffmann @ 2021-08-12  7:32 UTC (permalink / raw)
  To: Pavel Skripkin
  Cc: sumit.semwal, christian.koenig, dongwon.kim, linux-media,
	linaro-mm-sig, linux-kernel, syzbot+e9cd3122a37c5d6c51e8

On Wed, Aug 11, 2021 at 08:50:52PM +0300, Pavel Skripkin wrote:
> 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: syzbot+e9cd3122a37c5d6c51e8@syzkaller.appspotmail.com
> Fixes: 16c243e99d33 ("udmabuf: Add support for mapping hugepages (v4)")
> Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>

Pushed to drm-misc-next.

thanks,
  Gerd


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-12  7:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-11 17:50 [PATCH next] udmabuf: fix general protection fault in udmabuf_create Pavel Skripkin
2021-08-12  7:32 ` Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).