From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Liu Shixin <liushixin2@huawei.com>,
Andrew Morton <akpm@linux-foundation.org>,
Kefeng Wang <wangkefeng.wang@huawei.com>,
Kemeng Shi <shikemeng@huaweicloud.com>,
Mel Gorman <mgorman@techsingularity.net>,
David Hildenbrand <david@redhat.com>,
Matthew Wilcox <willy@infradead.org>,
Nanyong Sun <sunnanyong@huawei.com>,
Vlastimil Babka <vbabka@suse.cz>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/compaction: fix UBSAN shift-out-of-bounds warning
Date: Fri, 24 Jan 2025 18:07:35 +0800 [thread overview]
Message-ID: <a98753a8-a6df-41fa-956e-00f24f970b99@linux.alibaba.com> (raw)
In-Reply-To: <20250123021029.2826736-1-liushixin2@huawei.com>
On 2025/1/23 10:10, Liu Shixin wrote:
> syzkaller reported a UBSAN shift-out-of-bounds warning of (1UL << order)
> in isolate_freepages_block(). The bogus compound_order can be any value
> because it is union with flags. Add back the MAX_PAGE_ORDER check to fix
> the warning.
>
> Fixes: 3da0272a4c7d ("mm/compaction: correctly return failure with bogus compound_order in strict mode")
> Signed-off-by: Liu Shixin <liushixin2@huawei.com>
> ---
LGTM. And I remember Vlastimil had the same concern before[1].
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
[1]
https://lore.kernel.org/all/6b055821-ce14-4a6d-959c-25ade4a9bfd7@suse.cz/
> mm/compaction.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/mm/compaction.c b/mm/compaction.c
> index a2b16b08cbbff..384e4672998e5 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -630,7 +630,8 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
> if (PageCompound(page)) {
> const unsigned int order = compound_order(page);
>
> - if (blockpfn + (1UL << order) <= end_pfn) {
> + if ((order <= MAX_PAGE_ORDER) &&
> + (blockpfn + (1UL << order) <= end_pfn)) {
> blockpfn += (1UL << order) - 1;
> page += (1UL << order) - 1;
> nr_scanned += (1UL << order) - 1;
prev parent reply other threads:[~2025-01-24 10:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-23 2:10 Liu Shixin
2025-01-23 6:19 ` Kemeng Shi
2025-01-23 9:19 ` David Hildenbrand
2025-01-23 9:42 ` Oscar Salvador
2025-01-24 6:20 ` Andrew Morton
2025-01-24 9:05 ` David Hildenbrand
2025-01-26 2:05 ` Liu Shixin
2025-01-24 10:07 ` Baolin Wang [this message]
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=a98753a8-a6df-41fa-956e-00f24f970b99@linux.alibaba.com \
--to=baolin.wang@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liushixin2@huawei.com \
--cc=mgorman@techsingularity.net \
--cc=shikemeng@huaweicloud.com \
--cc=sunnanyong@huawei.com \
--cc=vbabka@suse.cz \
--cc=wangkefeng.wang@huawei.com \
--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