From patchwork Wed Jan 4 09:50:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Levi Yun X-Patchwork-Id: 38836 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp5057655wrt; Wed, 4 Jan 2023 01:52:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXswWYQtalDHkitVyjt7sVv8zrq1PCB05nlXem0Rbos+CMcd/WaanzpCzMO75qHPJp/IXo+7 X-Received: by 2002:a05:6a00:4c8c:b0:581:61a7:c8f0 with SMTP id eb12-20020a056a004c8c00b0058161a7c8f0mr28751669pfb.4.1672825944243; Wed, 04 Jan 2023 01:52:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672825944; cv=none; d=google.com; s=arc-20160816; b=FoHht8iZqyR90z1VT5Tc61MMG494GbmyCMNCnvDlmvYiddlGj5J3MEUVnzpYqmV8p2 igrsltPPaGiK5P2712m6RJ3AL5y0RrGyEll0s5vIbhP+A4oaXWUzhFaXvm1D7BBwYgBS Edz25gyYVzWcR5cVRLuZGBzCB3vS23JC1J9G+sO+jfLvchAJOXCURgNVkyWwy2F8pIc+ DXcQElFYueBf1kzSXqBRhIPjNPgPk4J8zczSNumKfczlkX5/XJLd7z4K+bduv8Ez8v/q HZBIKF4asH646x5wG0/X2cPZ4pcIt/ZttTgM+EM1C9Y4gCF0fbyNiaJ2Ykz0++OHZJo5 lMPQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d14-20020a056a00198e00b0057466de8ba2si37222208pfl.338.2023.01.04.01.52.11; Wed, 04 Jan 2023 01:52:24 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754085137368101418?= X-GMAIL-MSGID: =?utf-8?q?1754085137368101418?= __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; }