Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp13007294rwl; Wed, 4 Jan 2023 02:04:25 -0800 (PST) X-Google-Smtp-Source: AMrXdXs1n3Y6TlYEm0JlkA+LlSL5W5fTEfAH4wH0XWtwjeqNlP7ykcbKMdntzmTpOFIC5orpN+oO X-Received: by 2002:a05:6a20:8c1e:b0:ad:600c:54ae with SMTP id j30-20020a056a208c1e00b000ad600c54aemr45510522pzh.33.1672826665103; Wed, 04 Jan 2023 02:04:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672826665; cv=none; d=google.com; s=arc-20160816; b=FnwY9nYvtz25RbAHy4cVPzMz3jzbdHMkXEK1nT+2QGI9imkWuTw/aoGLgJV9TbkRDA YafxMmNPu8AxkBbG0ToTS4354yPNyJrN43bfPh+11SEQexPMlPcFMrJdWvxJelNzYG7+ /KcshXN5mCqL9logpHngaBQBGXeetIeg4n+FscZMw/hnQKU2SWwJlS3SvQbcZlfqkN3G hm0Cs4cpsgdWm72vxwVR3tN4gKIXTbgT9jh1UApvi5LK7Pu/B7fu2Lr6tH4NIKaPVOkl 93wg9wLypDjAl1rgxj2D3pIugg2ZxCKlAL04E4lhlfEsuen/RArIbYdH3Eg3NbGMtgg7 uNgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=mXu4eopB6IErZbHfllRnsHuODa6KsYR3AQ1R//XwFrg=; b=WVAi83KrxVc2AJLclgSCJU4HZUmLdY8klML9QXPvqUsog95m4bNTGvh+4Nh7pLfBlb bUa4AcYJa+GjYPKUEIOd6E0YUNpl+/NTKXU7rykOO0mi2B5xzpPxMyzex4u3oXR4MxD9 ILAFsYFECk8SJkQWN1EWrUEmNPZF6BztU5KhBrbpwrVuOvbYwuHzwR9nMBx9smJyfSFe P7l68Bn1SIYqHprp/KNdjxfdI5znfMbilquXpJSLsZ6tiyd+xZEE+pdwxms3vQPHqoKx cK1MwnSlpb49VP0pUj6e/ZyIhDnyB6LKkt5xTx651feq1WK0NGmjIBhE1eU4fjU17JTb QDHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dm6bFou2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x185-20020a6386c2000000b0049bdfffc5a8si22267597pgd.23.2023.01.04.02.04.17; Wed, 04 Jan 2023 02:04:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dm6bFou2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233997AbjADJv3 (ORCPT + 58 others); Wed, 4 Jan 2023 04:51:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234009AbjADJu5 (ORCPT ); Wed, 4 Jan 2023 04:50:57 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7234C13DE3 for ; Wed, 4 Jan 2023 01:50:56 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id jn22so35336496plb.13 for ; Wed, 04 Jan 2023 01:50:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mXu4eopB6IErZbHfllRnsHuODa6KsYR3AQ1R//XwFrg=; b=dm6bFou26k5Xmbtzuh722dWOfKUCn9EjjmCxyrgJvZjxV2+tAP3w1l8CH30ZhYSTwT pOr2GSaM1kD6Yv6FyCeGUD/MbuzxodJzZUO3RYWoWCqG0qAWn+iHlVN5Ws4iqFy+Xyxp s0q77LwOoJhfmdgUXuyKg1n/uuBI5DX5FJehdpD5myz9Qt/TpjolqhKYlyz3WjmqSx1a RYtVFyzvNyJhjxx76C5yj2oJsoqbNSZis5HKpmjVGL0JTN+7XpCXR3oimnCOnbvWGABx TVOiUGqoEO5uRmZX2egBR1l4kHUWU0jj0poJhrRLTfd4iGxBsuORw+gdabmrDATcvP/I UEwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mXu4eopB6IErZbHfllRnsHuODa6KsYR3AQ1R//XwFrg=; b=WNwNX8jrcwT3KayPswpetpAdNLjkITcGJmgGj8lbrmPSSbbaT7DJclnouLk1cUy4b3 /BJ/I/EjxhojxLcvMamLc8F5UWPRLi7vf6lqsvtilg/XTN3eJqbJxTrSfbn0tc+YGDKM JcRCr/KgfMd4p3j170Kr/YTM9pq/G+/dwrb89MZe5f6a+mTvnGAe+a62UICGSgRFXmza Nk0Y+Rkn5+oph1HjqPtJ1fAaGNd4U77f3BW1bF5on+ftNmFsvRr4G9tXLe7pD0hHEzuq mKRmh2UPS+Wpm6/KevVunToeZPzlKd25BZHz6/JQU1oVq8+jpATQULIP17waFNuT4u21 9CDA== X-Gm-Message-State: AFqh2kp7mLK9l4+BHWm8atGW4/klFNhICfAwgNj7VN+SByB87JPf14cZ mC4zEk2dq1QZLtk2naRP2tc= X-Received: by 2002:a17:90b:4c0f:b0:225:eb4b:222f with SMTP id na15-20020a17090b4c0f00b00225eb4b222fmr33844364pjb.45.1672825855885; Wed, 04 Jan 2023 01:50:55 -0800 (PST) Received: from localhost.localdomain ([118.235.15.65]) by smtp.gmail.com with ESMTPSA id t8-20020a17090a3b4800b002260c751b00sm13102610pjf.23.2023.01.04.01.50.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 04 Jan 2023 01:50:55 -0800 (PST) From: Levi Yun To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Levi Yun Subject: [PATCH] [PATCH] memblock: Fix return sizeless candidate on __memblock_find_range_top_down. Date: Wed, 4 Jan 2023 18:50:49 +0900 Message-Id: <20230104095049.59043-1-ppbuk5246@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __memblock_find_range_top_down can return start address of free region which sizeless then user speicified. To prevent the above case, add size check on candidate free region. Signed-off-by: Levi Yun --- mm/memblock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memblock.c b/mm/memblock.c index 511d4783dcf1..710e2ef8d67d 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -262,7 +262,7 @@ __memblock_find_range_top_down(phys_addr_t start, phys_addr_t end, continue; cand = round_down(this_end - size, align); - if (cand >= this_start) + if (cand >= this_start && this_end - cand >= size) return cand; } -- 2.35.1