summaryrefslogtreecommitdiff
path: root/lib/xarray.c
diff options
context:
space:
mode:
authorMatthew Wilcox (Oracle) <willy@infradead.org>2020-01-18 01:45:12 +0300
committerMatthew Wilcox (Oracle) <willy@infradead.org>2020-01-18 06:32:24 +0300
commit430f24f94c8a174d411a550d7b5529301922e67a (patch)
tree7a23f31ee6f3bca6a09e1ce0c23fa62d4e65c5e1 /lib/xarray.c
parent82a958497dc9120e0e8043da82273baedd255aaf (diff)
downloadlinux-430f24f94c8a174d411a550d7b5529301922e67a.tar.xz
XArray: Fix infinite loop with entry at ULONG_MAX
If there is an entry at ULONG_MAX, xa_for_each() will overflow the 'index + 1' in xa_find_after() and wrap around to 0. Catch this case and terminate the loop by returning NULL. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: stable@vger.kernel.org
Diffstat (limited to 'lib/xarray.c')
-rw-r--r--lib/xarray.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/xarray.c b/lib/xarray.c
index bfaaa2c1f3fe..6ecf35c2e1da 100644
--- a/lib/xarray.c
+++ b/lib/xarray.c
@@ -1849,6 +1849,9 @@ void *xa_find_after(struct xarray *xa, unsigned long *indexp,
XA_STATE(xas, xa, *indexp + 1);
void *entry;
+ if (xas.xa_index == 0)
+ return NULL;
+
rcu_read_lock();
for (;;) {
if ((__force unsigned int)filter < XA_MAX_MARKS)