From: Oleksii Kurochko <oleksii.kurochko@gmail.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Anthony PERARD" <anthony.perard@vates.tech>,
"Michal Orzel" <michal.orzel@amd.com>,
"Julien Grall" <julien@xen.org>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
xen-devel@lists.xenproject.org,
"Bernhard Kaindl" <bernhard.kaindl@citrix.com>
Subject: Re: [PATCH v2 1/2] xen/page_alloc: verify buddy alignment in reserve_offlined_page()
Date: Thu, 4 Jun 2026 11:43:15 +0200 [thread overview]
Message-ID: <ff4ecb07-7e97-4858-bdec-d85f25ad232d@gmail.com> (raw)
In-Reply-To: <a78c20d0-e894-467e-9eb8-4486bbdd1ac9@suse.com>
On 6/3/26 4:30 PM, Jan Beulich wrote:
> On 03.06.2026 16:17, Bernhard Kaindl wrote:
>> reserve_offlined_page() fails to verify alignment when growing
>> buddies around offlined pages. Consequently, misaligned buddies
>> may be constructed from non-offlined page ranges and returned to
>> the free lists.
>>
>> After a particular sequence of allocations and frees, pages
>> from such a misaligned buddy may be allocated more than once,
>> eventually triggering a Xen BUG() in alloc_heap_pages().
>>
>> Fixes: e4865c2315 ('Page offline support in Xen side')
>> Signed-off-by: Bernhard Kaindl <bernhard.kaindl@citrix.com>
>> Reviewed-by: Jan Beulich <jbeulich@suse.com>
>
> Oleksii, thoughts towards 4.22?
I've waited for v2 of this patch series to R-Ack, I see patches
separately but they aren't grouped into one patch series for some reason.
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
~ Oleksii
>
> Jan
>
>> ---
>> v2:
>> - Updated the title for clarity.
>> - Bugfix isolated from the test case for backporting.
>> - Removed excess parentheses from the alignment check if() expression.
>> - Simplified the alignment check to use '& (1UL << cur_order)'. Because
>> the covering buddy head is size-aligned, cur_head is also aligned to
>> cur_order, making this reduction safe (verified against extended tests).
>> - Updated the inline code comment to accurately state that only the upper
>> half of the next_order range is checked for offlined pages.
>> ---
>> xen/common/page_alloc.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
>> index 2c4ff2c34c70..2767376a710b 100644
>> --- a/xen/common/page_alloc.c
>> +++ b/xen/common/page_alloc.c
>> @@ -1202,6 +1202,11 @@ static int reserve_offlined_page(struct page_info *head)
>> if ( (cur_head + (1 << next_order)) >= (head + ( 1 << head_order)) )
>> goto merge;
>>
>> + /* Do not grow to next_order if cur_head is not aligned to it. */
>> + if ( mfn_x(page_to_mfn(cur_head)) & (1UL << cur_order) )
>> + goto merge;
>> +
>> + /* Check for offlined pages in upper half of next_order range. */
>> for ( i = (1 << cur_order), pg = cur_head + (1 << cur_order );
>> i < (1 << next_order);
>> i++, pg++ )
>
next prev parent reply other threads:[~2026-06-04 9:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 14:17 [PATCH v2 0/2] xen/mm: Ensure page offlining only creates properly aligned buddies Bernhard Kaindl
2026-06-03 14:17 ` [PATCH v2 1/2] xen/page_alloc: verify buddy alignment in reserve_offlined_page() Bernhard Kaindl
2026-06-03 14:30 ` Jan Beulich
2026-06-04 9:43 ` Oleksii Kurochko [this message]
2026-06-03 14:17 ` [PATCH v2 2/2] tools/tests: Regression test checking unaligned pages after offlining Bernhard Kaindl
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=ff4ecb07-7e97-4858-bdec-d85f25ad232d@gmail.com \
--to=oleksii.kurochko@gmail.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=bernhard.kaindl@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.