From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 467303F0A83; Wed, 20 May 2026 17:49:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779299344; cv=none; b=qdHmWJO3SoXAJc+/+yRUF0LgMZYhTf7+USa0rtQhjf5fcROoa2hbFAJzlBfKlo6egGKRKH4Y4idh3XCrves8+0HGYfoF7IFxHCbRZPmtrmeozwoIwKBbV1fGhvE66gxXyv3O19B31kIZl/emC3SLlxZGLaebuyqax70nZXMhxIw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779299344; c=relaxed/simple; bh=bxpids1Xz48lJezWT/os4neYIoq5+Yn3cgvcz74bcFg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CTWW4xdBEC4cU4lnS855DlzmZ1a9hZ5exj1fiihrny2qh/Z3MS4ciAKDy2a3X5h/aiwubVrh0+ssKOl0r8i9BDRBIMw/ksJ/nsCPUGiIMbEZmuYF9uMDsl3ImcLiFuZTJ/lsme1xm1k9ZNIOd7jlMCH9S5VgkQpAlXoK1fOd3Xw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=OHBsvAzo; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="OHBsvAzo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 369991F000E9; Wed, 20 May 2026 17:49:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779299342; bh=X2SCvSYwimcYvpj7pjViq5QZRfiMTAE7acSxskjNPxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OHBsvAzojDV4/E1wx9y56zLnGBSRp8zayIGkizK7V7TogdoguIhPIOc//O+s2uW6Y 2YLPl2uhtG+3yP91f7Ms8TKY/Zw6A2DyYOJFzQadMN8tLzxUED7MkcrLM/765bNn+q YNFGBoONNRxxC3qYAAE6ljn32BNuul+myp7SiN30= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, cuitao , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Tejun Heo , Sasha Levin Subject: [PATCH 6.18 735/957] cgroup/rdma: fix integer overflow in rdmacg_try_charge() Date: Wed, 20 May 2026 18:20:18 +0200 Message-ID: <20260520162150.498879589@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162134.554764788@linuxfoundation.org> References: <20260520162134.554764788@linuxfoundation.org> User-Agent: quilt/0.69 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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: cuitao [ Upstream commit c802f460dd485c1332b5a35e7adcfb2bc22536a2 ] The expression `rpool->resources[index].usage + 1` is computed in int arithmetic before being assigned to s64 variable `new`. When usage equals INT_MAX (the default "max" value), the addition overflows to INT_MIN. This negative value then passes the `new > max` check incorrectly, allowing a charge that should be rejected and corrupting usage to negative. Fix by casting usage to s64 before the addition so the arithmetic is done in 64-bit. Fixes: 39d3e7584a68 ("rdmacg: Added rdma cgroup controller") Signed-off-by: cuitao Reviewed-by: Michal Koutný Signed-off-by: Tejun Heo Signed-off-by: Sasha Levin --- kernel/cgroup/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/cgroup/rdma.c b/kernel/cgroup/rdma.c index ef5878fb20057..d544a747f3954 100644 --- a/kernel/cgroup/rdma.c +++ b/kernel/cgroup/rdma.c @@ -283,7 +283,7 @@ int rdmacg_try_charge(struct rdma_cgroup **rdmacg, ret = PTR_ERR(rpool); goto err; } else { - new = rpool->resources[index].usage + 1; + new = (s64)rpool->resources[index].usage + 1; if (new > rpool->resources[index].max) { ret = -EAGAIN; goto err; -- 2.53.0