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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240425113746.335530-7-kernel@pankajraghav.com>
Date: Thu, 25 Apr 2024 13:37:41 +0200
From: "Pankaj Raghav (Samsung)" <kernel@...kajraghav.com>
To: willy@...radead.org,
	djwong@...nel.org,
	brauner@...nel.org,
	david@...morbit.com,
	chandan.babu@...cle.com,
	akpm@...ux-foundation.org
Cc: linux-fsdevel@...r.kernel.org,
	hare@...e.de,
	linux-kernel@...r.kernel.org,
	linux-mm@...ck.org,
	linux-xfs@...r.kernel.org,
	mcgrof@...nel.org,
	gost.dev@...sung.com,
	p.raghav@...sung.com
Subject: [PATCH v4 06/11] filemap: cap PTE range to be created to i_size in folio_map_range()

From: Pankaj Raghav <p.raghav@...sung.com>

Usually the page cache does not extend beyond the size of the inode,
therefore, no PTEs are created for folios that extend beyond the size.

But with LBS support, we might extend page cache beyond the size of the
inode as we need to guarantee folios of minimum order. Cap the PTE range
to be created for the page cache by i_size.

A fstest has been created to trigger this edge case[1].

[1]https://lore.kernel.org/fstests/20240415081054.1782715-1-mcgrof@kernel.org/

Signed-off-by: Pankaj Raghav <p.raghav@...sung.com>
Co-Developed-by: Luis Chamberlain <mcgrof@...nel.org>
Signed-off-by: Luis Chamberlain <mcgrof@...nel.org>
---
 mm/filemap.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index f0c0cfbbd134..259531dd297b 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3600,12 +3600,15 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf,
 	}
 	do {
 		unsigned long end;
+		unsigned long i_size;
 
 		addr += (xas.xa_index - last_pgoff) << PAGE_SHIFT;
 		vmf->pte += xas.xa_index - last_pgoff;
 		last_pgoff = xas.xa_index;
 		end = folio_next_index(folio) - 1;
-		nr_pages = min(end, end_pgoff) - xas.xa_index + 1;
+		i_size = DIV_ROUND_UP(i_size_read(mapping->host),
+				      PAGE_SIZE) - 1;
+		nr_pages = min3(end, end_pgoff, i_size) - xas.xa_index + 1;
 
 		if (!folio_test_large(folio))
 			ret |= filemap_map_order0_folio(vmf,
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ