From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8128C2D0A3 for ; Thu, 29 Oct 2020 11:05:29 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6F61A20754 for ; Thu, 29 Oct 2020 11:05:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jLJpW1Hn"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="2l7+bdLs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F61A20754 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Owner; bh=WpUm3GZaomMjFuYqsqdt3/FapuEApYH8G6zweRl0v18=; b=jLJpW1HnDSJR1lGIqWFdtj8LSz eAibIeWjZQylX4gZ/M2vIrAC0oX2n2Zgghvi4bZ4g74SqvQKgLl5AgKxqBWJ1bqdxFIQUkZhBGZlQ IgxXSWJ5Zfk4L3u9CEgF/IM5NBiXRsBOeWt/bJnw14qZHxy3YjJBwUFL6f0WfriHmXo0EYPf7MBfs XWJHMIwsD31vV184J4NUvMnqlu64Qcr+1qyGj35ujQ4oLIApx18zTxG6G9ZwhGAsiXIygevKLVqDT bjv1oOHM+IBZrWRCWWQqi+ajFtlQVx/tDc/lWzf7R4DG+JE9tLgFp31sjxZrTT5mDhqbxXcVMbth9 uPtZwo8w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kY5ia-0007BG-8E; Thu, 29 Oct 2020 11:03:44 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kY5iX-0007A8-Bo for linux-arm-kernel@lists.infradead.org; Thu, 29 Oct 2020 11:03:42 +0000 Received: from e123331-lin.nice.arm.com (lfbn-nic-1-188-42.w2-15.abo.wanadoo.fr [2.15.37.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D4F4620754; Thu, 29 Oct 2020 11:03:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603969420; bh=acyncxg5wDmK6CNLmKA7z6UGUav7uI03MNVXwSyOnEI=; h=From:To:Cc:Subject:Date:From; b=2l7+bdLsxiEoowdZcFK8fSCWL8dc6VEbigghYpsfmRdAG96y63rpRU+TOb4VC3eRm SxGFfM/H8Drmgt7S9KEKWjfrVU10S2BXpHQh5zohudS/m+W2oBmOOmjJKratdUW6M/ ALKaey2MrK+zqmua8tZQZrtZMrdwYB5eoZK6f67Q= From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: highmem: avoid clobbering non-page aligned memory reservations Date: Thu, 29 Oct 2020 12:03:34 +0100 Message-Id: <20201029110334.4118-1-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201029_070341_549738_BD302BA9 X-CRM114-Status: GOOD ( 14.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linus.walleij@linaro.org, linux@armlinux.org.uk, stable@vger.kernel.org, Ard Biesheuvel MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org free_highpages() iterates over the free memblock regions in high memory, and marks each page as available for the memory management system. However, as it rounds the end of each region downwards, we may end up freeing a page that is memblock_reserve()d, resulting in memory corruption. So align the end of the range to the next page instead. Cc: Signed-off-by: Ard Biesheuvel --- arch/arm/mm/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index a391804c7ce3..d41781cb5496 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -354,7 +354,7 @@ static void __init free_highpages(void) for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE, &range_start, &range_end, NULL) { unsigned long start = PHYS_PFN(range_start); - unsigned long end = PHYS_PFN(range_end); + unsigned long end = PHYS_PFN(PAGE_ALIGN(range_end)); /* Ignore complete lowmem entries */ if (end <= max_low) -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8EB3C2D0A3 for ; Thu, 29 Oct 2020 11:03:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 571542076B for ; Thu, 29 Oct 2020 11:03:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603969421; bh=acyncxg5wDmK6CNLmKA7z6UGUav7uI03MNVXwSyOnEI=; h=From:To:Cc:Subject:Date:List-ID:From; b=edCCTLD4UTMheYDAOplj9DCLgm/LjLAScMj51sXtnBAVCGM7PmN2lJ7Tjz5JyErH7 dqwDlWEiTuidm0hIwGW6DKiAHYVEcHV/t5KPARZf/so5ErVZ1W1UCY7opJL6a5r0Es O6DUgxqWeTvbbETS7Tnl/XLHERM+hxg5Y5bmfpTM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727343AbgJ2LDl (ORCPT ); Thu, 29 Oct 2020 07:03:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:40282 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727294AbgJ2LDk (ORCPT ); Thu, 29 Oct 2020 07:03:40 -0400 Received: from e123331-lin.nice.arm.com (lfbn-nic-1-188-42.w2-15.abo.wanadoo.fr [2.15.37.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D4F4620754; Thu, 29 Oct 2020 11:03:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603969420; bh=acyncxg5wDmK6CNLmKA7z6UGUav7uI03MNVXwSyOnEI=; h=From:To:Cc:Subject:Date:From; b=2l7+bdLsxiEoowdZcFK8fSCWL8dc6VEbigghYpsfmRdAG96y63rpRU+TOb4VC3eRm SxGFfM/H8Drmgt7S9KEKWjfrVU10S2BXpHQh5zohudS/m+W2oBmOOmjJKratdUW6M/ ALKaey2MrK+zqmua8tZQZrtZMrdwYB5eoZK6f67Q= From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: linus.walleij@linaro.org, linux@armlinux.org.uk, Ard Biesheuvel , stable@vger.kernel.org Subject: [PATCH] ARM: highmem: avoid clobbering non-page aligned memory reservations Date: Thu, 29 Oct 2020 12:03:34 +0100 Message-Id: <20201029110334.4118-1-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org free_highpages() iterates over the free memblock regions in high memory, and marks each page as available for the memory management system. However, as it rounds the end of each region downwards, we may end up freeing a page that is memblock_reserve()d, resulting in memory corruption. So align the end of the range to the next page instead. Cc: Signed-off-by: Ard Biesheuvel --- arch/arm/mm/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index a391804c7ce3..d41781cb5496 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -354,7 +354,7 @@ static void __init free_highpages(void) for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE, &range_start, &range_end, NULL) { unsigned long start = PHYS_PFN(range_start); - unsigned long end = PHYS_PFN(range_end); + unsigned long end = PHYS_PFN(PAGE_ALIGN(range_end)); /* Ignore complete lowmem entries */ if (end <= max_low) -- 2.17.1