From nobody Tue Dec 2 02:31:05 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 E546832D7FC for ; Wed, 19 Nov 2025 22:42:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592168; cv=none; b=d1FI8MmMZJ0IqFX+jtALNxzEwoqINXaC8WlkaMNJ7/yvS5xVL39T5o7ATKoP5zbzBpYBMt3B/hsEgNp/dlBQgwX1YfrhL52PwCpcmq8sk6xupiSe4mnDzt/Q/oAqjfjp0djRa031ufCzi4YUu/Rz6L7eNNebUHd6btLHyLMTVkI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592168; c=relaxed/simple; bh=IG3afSJYxIMPbWj8qHS465BEo1xpWrZZeTJqB1zXaPA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gc7ZqErrVYZ+3cOJu6dhWOGJzBxrSG2/CYjCIiZ9sFuDjmrPMk/tBBKpjraN4858r6vj1W8RB41Johd11t6zRq5bp4DCteVU6FcqsjrFr3TAhplFuOjPfDb5PuP1ax/gXOwAOwHf8lSnvORnpodzSQB5wGjQtmxveLH/AkNw6w0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=GFeWqRHO; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="GFeWqRHO" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqss-006kto-Rc for linux-kernel@vger.kernel.org; Wed, 19 Nov 2025 23:42:42 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=zQju7qyVPpm7bTqGjDsv8+EOunlz4aOhCwApp83FVt8=; b=GFeWqRHOD/Wlz8ZMlnlnpOgmht vKIVXzGSAuMK+33k5FwyRXkgNS3fJ9VLZ173sKzPoemNk8yVMFRyg24S5XJ2tBJRn0UXWThIT8Vq+ JGf6NcMWU3ECtpg1VL/MXoXZ4JZbAb3aOwLB+bjnhuJXig5nc5VdvoyMj5BeCWT+Al135vX9EVlwo hDdHZQLtx5hOjcmCku11Vhw2nbk+bjw1sfiT2fF12ueeRIKILR+CY3SyQ628eqUEqoUnAsh8JRCh7 v5mEX8IaIYiTHWD2bs15ilxvNikz7b69C64uGGkSE5pIzKbbo0LCo9/gSOeTFh6wdQYfLQBSiAqRu RpAv7bZw==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqss-00085T-Gt; Wed, 19 Nov 2025 23:42:42 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsW-00Fos6-7E; Wed, 19 Nov 2025 23:42:20 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org Cc: David Laight Subject: [PATCH 05/44] ipc/msg: Fix saturation of percpu counts in msgctl_info() Date: Wed, 19 Nov 2025 22:41:01 +0000 Message-Id: <20251119224140.8616-6-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight While the percpu_counter_sum() values are unlikely to be large the code tries to saturate them using min_t(int, percpu_counter_sum(), INT_MAX) This just doesn't work since the high bits are all masked and then the (possibly negative) value assigned. Replace the min_t() with a plain min(). Fixes: 72d1e611082ed ("ipc/msg: mitigate the lock contention with percpu co= unter") Signed-off-by: David Laight --- ipc/msg.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ipc/msg.c b/ipc/msg.c index ee6af4fe52bf..34e607add006 100644 --- a/ipc/msg.c +++ b/ipc/msg.c @@ -501,11 +501,9 @@ static int msgctl_info(struct ipc_namespace *ns, int m= sqid, max_idx =3D ipc_get_maxidx(&msg_ids(ns)); up_read(&msg_ids(ns).rwsem); if (cmd =3D=3D MSG_INFO) { - msginfo->msgmap =3D min_t(int, - percpu_counter_sum(&ns->percpu_msg_hdrs), + msginfo->msgmap =3D min(percpu_counter_sum(&ns->percpu_msg_hdrs), INT_MAX); - msginfo->msgtql =3D min_t(int, - percpu_counter_sum(&ns->percpu_msg_bytes), + msginfo->msgtql =3D min(percpu_counter_sum(&ns->percpu_msg_bytes), INT_MAX); } else { msginfo->msgmap =3D MSGMAP; --=20 2.39.5