lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210913081113.79975-1-xu.xin16@zte.com.cn>
Date:   Mon, 13 Sep 2021 08:11:13 +0000
From:   cgel.zte@...il.com
To:     akpm@...ux-foundation.org
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        xu xin <xu.xin16@....com.cn>, Zeal Robot <zealci@....com.cn>
Subject: [PATCH linux-next] mm/folio-compat: fix potential NULL pointer access 

From: xu xin <xu.xin16@....com.cn>

The pointer 'folio' might be NULL, but the structure it points to is accessed.
Accordingly, we add a check of NULL pointer by 'if (!folio)'.
Secondly, there is no need to check if folio is pointer or value with 'xa_is_value(folio)' 
because folio is alwayse pointer.

Reported-by: Zeal Robot <zealci@....com.cn>
Signed-off-by: xu xin <xu.xin16@....com.cn>
---
 mm/folio-compat.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/folio-compat.c b/mm/folio-compat.c
index 5b6ae1da314e..a1b60310c7ba 100644
--- a/mm/folio-compat.c
+++ b/mm/folio-compat.c
@@ -123,7 +123,9 @@ struct page *pagecache_get_page(struct address_space *mapping, pgoff_t index,
 	struct folio *folio;
 
 	folio = __filemap_get_folio(mapping, index, fgp_flags, gfp);
-	if ((fgp_flags & FGP_HEAD) || !folio || xa_is_value(folio))
+	if (!folio)
+		return NULL;
+	if ((fgp_flags & FGP_HEAD))
 		return &folio->page;
 	return folio_file_page(folio, index);
 }
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ