diff options
author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2020-01-18 01:45:12 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-01-29 18:45:26 +0300 |
commit | a5135ca1f92a7b201b7f8297f42b8579f92bc55d (patch) | |
tree | 186501e471fdb0e5e845e9bddb03e5144d1c3051 /lib/xarray.c | |
parent | b8560e3d90afad8c5ee1ae4fea41949a76b5bb8b (diff) | |
download | linux-a5135ca1f92a7b201b7f8297f42b8579f92bc55d.tar.xz |
XArray: Fix infinite loop with entry at ULONG_MAX
commit 430f24f94c8a174d411a550d7b5529301922e67a upstream.
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
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib/xarray.c')
-rw-r--r-- | lib/xarray.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/xarray.c b/lib/xarray.c index 1237c213f52b..ab842cff4634 100644 --- a/lib/xarray.c +++ b/lib/xarray.c @@ -1847,6 +1847,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) |