libnbd/0005-copy-file-ops.c-Fix-page-eviction-when-len-page_size.patch
DistroBaker bd814fcc34 Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/libnbd.git#b5a71ab87ad8c2289fbd2364fae2fe7c2c3629b8
2021-03-19 14:45:29 +00:00

33 lines
1.1 KiB
Diff

From 107eb605cfb75238020332b5a5461d0e09d62bec Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Wed, 3 Mar 2021 12:51:51 +0100
Subject: [PATCH 5/6] copy/file-ops.c: Fix page eviction when len < page_size.
On Fedora ppc64le at the moment page size is 64K. When asked to evict
a range with length < 64K the length calculation wrapped around and it
tried to evict a huge number of pages beyond the end of the file.
With Nir's commit 0f6e4f38b this (correctly) resulted in an assertion
failure.
Fix this by checking for the overflow and returning early.
---
copy/file-ops.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/copy/file-ops.c b/copy/file-ops.c
index 47ec768..6bad50c 100644
--- a/copy/file-ops.c
+++ b/copy/file-ops.c
@@ -155,6 +155,7 @@ page_cache_evict (struct rw_file *rwf, uint64_t orig_offset, size_t orig_len)
/* Only bother with whole pages. */
offset = ROUND_UP (orig_offset, page_size);
+ if (orig_len < offset - orig_offset) return;
len = orig_len - (offset - orig_offset);
len = ROUND_DOWN (len, page_size);
--
2.29.0.rc2