From: Wei Yang <richard.weiyang@gmail.com>
To: willy@infradead.org
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
hannes@cmpxchg.org, shakeelb@google.com,
Wei Yang <richard.weiyang@gmail.com>,
Muchun Song <songmuchun@bytedance.com>,
Vlastimil Babka <vbabka@suse.cz>
Subject: [PATCH] XArray: fix xas_split_alloc() on checking split limit
Date: Sun, 23 Oct 2022 06:25:02 +0000 [thread overview]
Message-ID: <20221023062502.29429-1-richard.weiyang@gmail.com> (raw)
We limit the range on split, so that we can just allocate (sibs + 1)
nodes to meet the need. This means new order at most could be on the
next level of old order. But current range check doesn't cover the case
well.
For example, if old order is (3 * XA_CHUNK_SHIFT), new order with
XA_CHUNK_SHIFT could pass the check now. This means new order is on the
second level of old order.
This patch do the check on shift directly to make sure the range is in
limit.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Johannes Weiner <hannes@cmpxchg.org>
CC: Shakeel Butt <shakeelb@google.com>
CC: Muchun Song <songmuchun@bytedance.com>
CC: Vlastimil Babka <vbabka@suse.cz>
---
lib/xarray.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/xarray.c b/lib/xarray.c
index aa9dc9b9417f..2c13fd9a9cf2 100644
--- a/lib/xarray.c
+++ b/lib/xarray.c
@@ -1019,10 +1019,11 @@ void xas_split_alloc(struct xa_state *xas, void *entry, unsigned int order,
gfp_t gfp)
{
unsigned int sibs = (1 << (order % XA_CHUNK_SHIFT)) - 1;
+ unsigned int xa_shift = order - (order % XA_CHUNK_SHIFT);
unsigned int mask = xas->xa_sibs;
/* XXX: no support for splitting really large entries yet */
- if (WARN_ON(xas->xa_shift + 2 * XA_CHUNK_SHIFT < order))
+ if (WARN_ON(xas->xa_shift + XA_CHUNK_SHIFT < xa_shift))
goto nomem;
if (xas->xa_shift + XA_CHUNK_SHIFT > order)
return;
--
2.33.1
reply other threads:[~2022-10-23 6:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221023062502.29429-1-richard.weiyang@gmail.com \
--to=richard.weiyang@gmail.com \
--cc=hannes@cmpxchg.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shakeelb@google.com \
--cc=songmuchun@bytedance.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).