Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1942368imn; Mon, 1 Aug 2022 05:52:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR7kSuRmNzAw5IYeNCuFpXsc99+Ho9C/h2YCWs59DI5KV8ci/nG5TKHAKAqS+726YDFQB5B+ X-Received: by 2002:a17:907:67b0:b0:730:679d:ac80 with SMTP id qu48-20020a17090767b000b00730679dac80mr5358105ejc.566.1659358375296; Mon, 01 Aug 2022 05:52:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659358375; cv=none; d=google.com; s=arc-20160816; b=xw48DgFzD9FF8ofbvWWNGIMskULe0hWZYhplMIkFMCaqQxXDx/2OiFBBf2Fv+MYlsI 9zWZJHPQa8tRyG07DeGTqQK4KpXeH5B6jnMzjtoSiNAFoG9sQNHHs0sPk7jDZ35UWceX cEFstBMaxbVlHB5C9BZnc1JawhIZyN1QefTFIXT7D1hrRcwlxBiGwCNzpBjX8OiQzJmq b2zSV0v3W+4DC+U5CerBYWfN7d4g2kdJGJgghexbvEFpbKIuRa9EpdXNX6GuP5YBvKWF 4cVpEF5SDgUvpDNtZH1Vvhq/1rnhZ+kHDv539HQaGV7829bxOIgo5EP3xGbkqwNGMJrR mr6g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7+QpXV6hPrHAhp/fygOPtCPTkhFknEGhvwaE1TGHgjI=; b=wK2xUjXrv/RAqsNPn1sWFJ0Pe2JSb8QshSxY01A9GXLpjjT73IlElzW6rFubnNrqX0 bBxg5fElbFf9dxwLomeXvE9q5pacK3rvZAlNGWi81G3F+2xJXDlShAfk+TNZq+VGKIcK Xre9pEeLBgHyno4Aam03NdYOawaDglYMoQfuw0w1dV+gw/wdts9+iRhPg4TmP/9o4Olb 1QRKBERyfEmOFg4mfGA4L852tahvZBZ/QxSrnOB+V31hUE2lt8fuN+ePctH+Tka7kACF put/R85QqxgndGHi1zX0GHi/uKOvDl0GVIuwRXy1FGdYkXOfarILGL2qXWu2gP0dPdK4 eHeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Do9arLBY; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a15-20020a05640213cf00b0043d64c59b10si4386016edx.94.2022.08.01.05.52.30; Mon, 01 Aug 2022 05:52:55 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=Do9arLBY; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234587AbiHAMSp (ORCPT + 99 others); Mon, 1 Aug 2022 08:18:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234586AbiHAMSI (ORCPT ); Mon, 1 Aug 2022 08:18:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25D8D49B5F; Mon, 1 Aug 2022 04:59:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DE1E7601C5; Mon, 1 Aug 2022 11:59:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECAFAC433C1; Mon, 1 Aug 2022 11:59:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1659355154; bh=Kr1Yx27AWLh+1gvT8gaFpSOhnROqSVu0uXH2DRg+H2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Do9arLBY+JWYTpX3rV3riVQc8B4YmT/P7Jcpd3qt2wYoGmbYLgJ0dz8PboAHEksJ3 ShVofVkMRczbF6iYm4U84Ox15cWQ238asHFo1FUNeC19EP2KVUg9TjGUEVBcSef0+4 7uN8SYxvP3rKv0AyD2zyZrEqifs+zo2i9cHJ/Jy4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Fainelli , Linus Walleij , "Russell King (Oracle)" , Sasha Levin Subject: [PATCH 5.18 82/88] ARM: 9216/1: Fix MAX_DMA_ADDRESS overflow Date: Mon, 1 Aug 2022 13:47:36 +0200 Message-Id: <20220801114141.740058208@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220801114138.041018499@linuxfoundation.org> References: <20220801114138.041018499@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Florian Fainelli [ Upstream commit fb0fd3469ead5b937293c213daa1f589b4b7ce46 ] Commit 26f09e9b3a06 ("mm/memblock: add memblock memory allocation apis") added a check to determine whether arm_dma_zone_size is exceeding the amount of kernel virtual address space available between the upper 4GB virtual address limit and PAGE_OFFSET in order to provide a suitable definition of MAX_DMA_ADDRESS that should fit within the 32-bit virtual address space. The quantity used for comparison was off by a missing trailing 0, leading to MAX_DMA_ADDRESS to be overflowing a 32-bit quantity. This was caught thanks to CONFIG_DEBUG_VIRTUAL on the bcm2711 platform where we define a dma_zone_size of 1GB and we have a PAGE_OFFSET value of 0xc000_0000 (CONFIG_VMSPLIT_3G) leading to MAX_DMA_ADDRESS being 0x1_0000_0000 which overflows the unsigned long type used throughout __pa() and then __virt_addr_valid(). Because the virtual address passed to __virt_addr_valid() would now be 0, the function would loudly warn and flood the kernel log, thus making the platform unable to boot properly. Fixes: 26f09e9b3a06 ("mm/memblock: add memblock memory allocation apis") Signed-off-by: Florian Fainelli Reviewed-by: Linus Walleij Signed-off-by: Russell King (Oracle) Signed-off-by: Sasha Levin --- arch/arm/include/asm/dma.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/include/asm/dma.h b/arch/arm/include/asm/dma.h index a81dda65c576..45180a2cc47c 100644 --- a/arch/arm/include/asm/dma.h +++ b/arch/arm/include/asm/dma.h @@ -10,7 +10,7 @@ #else #define MAX_DMA_ADDRESS ({ \ extern phys_addr_t arm_dma_zone_size; \ - arm_dma_zone_size && arm_dma_zone_size < (0x10000000 - PAGE_OFFSET) ? \ + arm_dma_zone_size && arm_dma_zone_size < (0x100000000ULL - PAGE_OFFSET) ? \ (PAGE_OFFSET + arm_dma_zone_size) : 0xffffffffUL; }) #endif -- 2.35.1