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 805052210E1; Thu, 12 Dec 2024 16:19:55 +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=1734020395; cv=none; b=OC4QHXNAg0riCsqhPjDBArVlWPGP7ksK09OjKsoYMeOGjlE3VCe8fX5T4ZHzYJoRTAr8H+IZy9xpzMln3gHu5Xjv6r8DhfgL8FjSAkgjpdmQlO30ReH5xY/vvqk7DQfn/vzU87SmWDgJrPeeq5FwRVbP+RNLsJ3KYcI0JomRM50= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734020395; c=relaxed/simple; bh=k4D0/DIT6CgsnOtR1BSEr5PVoGELu+2nsHHy0QXdxYw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZEDjEaBlZN2CxVQVf4mj6FlbcpjtK/o6RbywUR8iCDCIquB5K4qys3uAp2y1nzHomdvNK/MNW/FGLmt/EK9exIisWQbrRbqe7wyF3o8ptnPwrS8EsxLV1Twd0wAd1B5eXguYKJuYv88gRv6GIzzYii2QYYDL0LViWU/Ur5oLlfk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=oQKrlvWE; 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="oQKrlvWE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E197AC4CECE; Thu, 12 Dec 2024 16:19:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1734020395; bh=k4D0/DIT6CgsnOtR1BSEr5PVoGELu+2nsHHy0QXdxYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oQKrlvWE0qZQ5rkbJDjEQnRObJHzzVA1aOiIomd4JpZBU01PyZiHhfLh4bJx+SRNj E1y23eceBmpBnxAO+sigCJaz4UmO7q08DTKumg3TFDdvV4oBXTOFdm/bBcxpeegbLw ZxSLa/Km6rNYfgsz2WY8NihlSdJxpCNWpRh0E9Ig= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tiwei Bie , Johannes Berg , Sasha Levin Subject: [PATCH 6.1 426/772] um: Fix potential integer overflow during physmem setup Date: Thu, 12 Dec 2024 15:56:11 +0100 Message-ID: <20241212144407.524457727@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241212144349.797589255@linuxfoundation.org> References: <20241212144349.797589255@linuxfoundation.org> User-Agent: quilt/0.67 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-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tiwei Bie [ Upstream commit a98b7761f697e590ed5d610d87fa12be66f23419 ] This issue happens when the real map size is greater than LONG_MAX, which can be easily triggered on UML/i386. Fixes: fe205bdd1321 ("um: Print minimum physical memory requirement") Signed-off-by: Tiwei Bie Link: https://patch.msgid.link/20240916045950.508910-3-tiwei.btw@antgroup.com Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- arch/um/kernel/physmem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c index 91485119ae67a..4339580f5a4f6 100644 --- a/arch/um/kernel/physmem.c +++ b/arch/um/kernel/physmem.c @@ -80,10 +80,10 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end, unsigned long len, unsigned long long highmem) { unsigned long reserve = reserve_end - start; - long map_size = len - reserve; + unsigned long map_size = len - reserve; int err; - if(map_size <= 0) { + if (len <= reserve) { os_warn("Too few physical memory! Needed=%lu, given=%lu\n", reserve, len); exit(1); @@ -94,7 +94,7 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end, err = os_map_memory((void *) reserve_end, physmem_fd, reserve, map_size, 1, 1, 1); if (err < 0) { - os_warn("setup_physmem - mapping %ld bytes of memory at 0x%p " + os_warn("setup_physmem - mapping %lu bytes of memory at 0x%p " "failed - errno = %d\n", map_size, (void *) reserve_end, err); exit(1); -- 2.43.0