Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2400468lqp; Sun, 24 Mar 2024 17:55:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUIp+ouLrV3m9Wrpeysaerd6YujVxGbGSC6zHJXN0A5YNkXVjme5PJxme+M0pLXco7P7e+L8K26q4TYzbIL5emDwEpk0WuXnNK0zQ4jEQ== X-Google-Smtp-Source: AGHT+IHAqgDUVrpI2KM+9uOEICXP6Q0Rs1CfeJ/jNQvvTqLVkgFL45vqvQcTovHYPpNR9ntJb11s X-Received: by 2002:a05:6358:891:b0:17c:1bef:4077 with SMTP id m17-20020a056358089100b0017c1bef4077mr6842975rwj.3.1711328106597; Sun, 24 Mar 2024 17:55:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711328106; cv=pass; d=google.com; s=arc-20160816; b=B+fr1wNbD2vZfvIWOLAucd7dO90SE7LtGqCv1C+VjRfUkVgxcjsnZXMDnyw+swNJYv sxcnBDCoOvmjPfhHw9KrarHG1I3Ytrn0gbpYXintAYZ2YNVy4Zit/DHQsUA7+W6HEQaK UyNMGnpex30iBU/HQuoJsNjocI/hUS5zpRBD1I0M4oZCmF2gVlrZZdj/5cmmgtYOWame mA72vAZgcE0I8Fs15F9+Bgc5VG9qTZ2vTXS1/Z5hxqVwNXGtKtm6WMNqUxI+hOQefOTx 18iKDF0zJEJlJ0V4/0AZVlcOJ7r+uQB6IXKJIkezBSW+R3XKskOydHNt0lkkbq7lO+zr dezg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=gjyzbEyGGdys8U0b2XKF5QmBmsarNlbSecZ8ZONy/vs=; fh=upX20gtSdYFXdBD02ySyoqaMtXx5vXY+yMWUH5AO7Us=; b=0+W2Vn4JqRVNlnIPkkiBcG/BACfnzB6CKgnRRDCy5fmN95wITilXPp0LLP4U4oVNIT +rzLLQiht2fWpyua0GIewlHMT1XRM2JUCGytZqlsLydYMH8py+64YJFegJV3aeTRjHbb iVqcWw6qIgUceEWQRhYqeDwzt3gcLvN7Qn9Dafk2rLbcznLRCP0SoQGOulds8yf6D2rB M9nsAoLox6exubd/0tHH0dp/LLUGk6ibuGxwbzdLYfDlfqEmF8mtlBECsjHoO0vu2SP7 ezftavgFbde1oohHapBZKjLRykxrty9euO4DQY3hDWlvuS37DW4hGz8YquY+5un78pKJ iWoA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XfEw7QwL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113404-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113404-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j16-20020a635950000000b005d8d56cd646si6453276pgm.130.2024.03.24.17.55.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:55:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113404-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XfEw7QwL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113404-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113404-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2065F28693B for ; Mon, 25 Mar 2024 00:28:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3905F1A50F9; Sun, 24 Mar 2024 22:43:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XfEw7QwL" 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 561491A50DF; Sun, 24 Mar 2024 22:43:26 +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=1711320206; cv=none; b=Yk9+9STRYlWp2gjXNKEi/84l+spwDF68rBCyMWn0L9sZ12izZT0Ni4kavK3jtnLZfZAuKdFb5CmJa83pN4odDB4fEpJBc6rk+LOoBEg87lmJrcXoqObQJmP8nlKNgu+MDXSAGqJGUHt6HqNQlLQWreqDwFT/I6ySnajF1wFAoNM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320206; c=relaxed/simple; bh=5quXF4FdgTJX7eNpmboTLcTJhuBwuYS8glB/aHDKKD4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Svq+JMCGimaF1bremMwuZ1JEL3eBh31eM+Y3qHPtj/gZP41j39zPKk9KDoLR7hIMO5sRq0/Anu4vU14QXgpbCuotfFV0FncVRlpHu6IkTeNfMx0PJIh8x/QLJDlJhBImmWK6BVOQdY71C/VNx7fQ12biIWP35ArGNDlbn0gTVYE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XfEw7QwL; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A407C433C7; Sun, 24 Mar 2024 22:43:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320206; bh=5quXF4FdgTJX7eNpmboTLcTJhuBwuYS8glB/aHDKKD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XfEw7QwLVwfzBZ+4b+OPofR1j5evLsPFwrWAKbpfFhuJBvwPXxy7JJWa2c7uWcwud REq61ScBVrwZbz8tkMdFInb8ecfgvgBP4ZD39zd5ru9h89bUo7qpYUoEbda5nPCRdQ uUxKar0eZKrN2RHz+OhWCDAvAs6DyVw9aSGtzaDwKrad1pTXTp8p339dUFU3V0KS3a wcDQkbBzfamAXRXfFTAaYU3fMNzZPU4HxpYZ+9djo5kV0D1Nu9NLcQWpPja77qEgLP iMs6EDP2cNr+NEsmmkljkPq6X3fGHRvM+mj0NE2FP7MHscijbf5yNI8OOs0SX+Tsny HWJZfO7KLQWLg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dan Carpenter , Alexander Potapenko , Andrey Konovalov , Andrew Morton , Sasha Levin Subject: [PATCH 6.8 513/715] lib/stackdepot: off by one in depot_fetch_stack() Date: Sun, 24 Mar 2024 18:31:32 -0400 Message-ID: <20240324223455.1342824-514-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Dan Carpenter [ Upstream commit dc24559472a682eb124e869cb110e7a2fd857322 ] The stack_pools[] array has DEPOT_MAX_POOLS. The "pools_num" tracks the number of pools which are initialized. See depot_init_pool() for more details. If pool_index == pools_num_cached, this will read one element beyond what we want. If not all the pools are initialized, then the pool will be NULL, triggering a WARN(), and if they are all initialized it will read one element beyond the end of the array. Link: https://lkml.kernel.org/r/361ac881-60b7-471f-91e5-5bf8fe8042b2@moroto.mountain Fixes: b29d31885814 ("lib/stackdepot: store free stack records in a freelist") Signed-off-by: Dan Carpenter Cc: Alexander Potapenko Cc: Andrey Konovalov Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- lib/stackdepot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index c043a4186bc59..c1ec2b4b6dabf 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -490,7 +490,7 @@ static struct stack_record *depot_fetch_stack(depot_stack_handle_t handle) lockdep_assert_not_held(&pool_lock); - if (pool_index > pools_num_cached) { + if (pool_index >= pools_num_cached) { WARN(1, "pool index %d out of bounds (%d) for stack id %08x\n", pool_index, pools_num_cached, handle); return NULL; -- 2.43.0