From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1760155756; Wed, 5 Feb 2025 14:29:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738765783; cv=none; b=m1zw4Ti3j2ZdtFcMUyx4mDJ0h2Hxj8MPA1v6+80PdOyP8ybelhwYm7wM84JrO0NPRNhpfTpWhvx3r1X9frLyI+xOKFIyql6D9zT9ebFW2YyJrvNBJMyVJ/83WZU6lYB+AbohA3gSI8eWepEtOe75UhR3gXx25hFPCbl9WbSE2Vs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738765783; c=relaxed/simple; bh=eX5MD+e5e5zf7NGsyh7g8JU//yaORqkNHezkuxm6Wao=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=c/Di/KN+5qQwlTCNSyGeOaXgxN0m5mpwFlb5RkcqJ7VmJHZcASa7F+cnDjUepsiGWsYZbHFwC/KRbtOyWfyZK4CjeVpAPQMkiN6tkKuqHdgqf3AezrDThIsq983EjfVzWtbRb96agXpu+OUfeha/Ggfjlh8SU/oG29bdK3TKjhs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ip7jYz9O; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ip7jYz9O" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EC49C4CED1; Wed, 5 Feb 2025 14:29:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738765783; bh=eX5MD+e5e5zf7NGsyh7g8JU//yaORqkNHezkuxm6Wao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ip7jYz9O44vJJqbUBs8CteDnoHwpPiFrr3jwGLgkgT5lKYQQpLTJjLNcLd7/jzGQM 3HbZPctcSX5IQ/69VQJBMZUYryuGdu6tVmiC4PnAKck8rJfvnkHNn1taqk+mVvZMU1 F2f8gftwRu5JhkTo5wGORulstp0Wze72E0+zRWOY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Lad Prabhakar , King Dix , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Sasha Levin Subject: [PATCH 6.6 298/393] PCI: rcar-ep: Fix incorrect variable used when calling devm_request_mem_region() Date: Wed, 5 Feb 2025 14:43:37 +0100 Message-ID: <20250205134431.713424641@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250205134420.279368572@linuxfoundation.org> References: <20250205134420.279368572@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: King Dix [ Upstream commit 2d2da5a4c1b4509f6f7e5a8db015cd420144beb4 ] The rcar_pcie_parse_outbound_ranges() uses the devm_request_mem_region() macro to request a needed resource. A string variable that lives on the stack is then used to store a dynamically computed resource name, which is then passed on as one of the macro arguments. This can lead to undefined behavior. Depending on the current contents of the memory, the manifestations of errors may vary. One possible output may be as follows: $ cat /proc/iomem 30000000-37ffffff : 38000000-3fffffff : Sometimes, garbage may appear after the colon. In very rare cases, if no NULL-terminator is found in memory, the system might crash because the string iterator will overrun which can lead to access of unmapped memory above the stack. Thus, fix this by replacing outbound_name with the name of the previously requested resource. With the changes applied, the output will be as follows: $ cat /proc/iomem 30000000-37ffffff : memory2 38000000-3fffffff : memory3 Fixes: 2a6d0d63d999 ("PCI: rcar: Add endpoint mode support") Link: https://lore.kernel.org/r/tencent_DBDCC19D60F361119E76919ADAB25EC13C06@qq.com Tested-by: Lad Prabhakar Signed-off-by: King Dix [kwilczynski: commit log] Signed-off-by: Krzysztof WilczyƄski Reviewed-by: Lad Prabhakar Reviewed-by: Manivannan Sadhasivam Signed-off-by: Sasha Levin --- drivers/pci/controller/pcie-rcar-ep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/controller/pcie-rcar-ep.c b/drivers/pci/controller/pcie-rcar-ep.c index f9682df1da619..209719fb6ddcc 100644 --- a/drivers/pci/controller/pcie-rcar-ep.c +++ b/drivers/pci/controller/pcie-rcar-ep.c @@ -107,7 +107,7 @@ static int rcar_pcie_parse_outbound_ranges(struct rcar_pcie_endpoint *ep, } if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res), - outbound_name)) { + res->name)) { dev_err(pcie->dev, "Cannot request memory region %s.\n", outbound_name); return -EIO; -- 2.39.5