From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f46.google.com (mail-dl1-f46.google.com [74.125.82.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB8A12D8DD0 for ; Tue, 16 Jun 2026 11:20:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781608826; cv=none; b=Iq1Yxer+ct1K+x6nNuR90AZ7WipMglnh9/q9wyS4iZmC2gDk3sbn+TU4tawJYH+Hjgncxf2qMkCQJyD9So8oprgVSC8UMkIu23wDUbI0NgNKjyfF7KEupOhpAloQ8Jitk8ehnzMCSsGK8x6RI6M4kTHfN4MCBKlyuaQlOswPlBM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781608826; c=relaxed/simple; bh=dwhTvCfrRGEdkS5fblwGbN3WswtNWzVGIi/Hr3GNOL8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=idUfMEGgTc38eDVRreIxKRAA/EfFgg0JzpgbhpCoqcignLcNHTBqOdcZydsdLiKZHwFUFQmWd2NHYJH+yIbyE12HghKTl1qG+CiwcFxziLaOjmgmZkv2tPx8PJvovF/YIhj/W8gxAxO/U5fumP+XFcDzMO5RWevxOV1zQGH6D9o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JZ28snqP; arc=none smtp.client-ip=74.125.82.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JZ28snqP" Received: by mail-dl1-f46.google.com with SMTP id a92af1059eb24-137335bc3caso5285891c88.0 for ; Tue, 16 Jun 2026 04:20:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781608825; x=1782213625; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=sj4/1zOXXUNqP2YBqExNKT9kqAWy67bgeTiSkUWpqNQ=; b=JZ28snqP8xVsRgZ0+LXS2pf9JJVjjITc4pRxh/h69Jwd44OigyEXqUvoXCaSQMAcwh cEH5qluIWudEgf44XCoWY9rcV+TP6U/7aGrZ3HkkvzZh/43/9xlar106NMpbpusWIKOp aJIG3XTgby/kbZGHL+/cDFSQrICXylAIWPLRnH15Woz25rQpMawWySuUjY8Nd5S8TcEb kfGL8CBiFhyxIYjvhCzUaRkh/GuPpCKvu880cNPaZ2MTHnellc/t+i7aogD41xnZjhi0 hFZ6wGzUNx7oPOKj6aXKFFusssM1Co+TGWRAMQxft/pWU5ufd+KVFuAOkhmrZHP4sUjy g5WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781608825; x=1782213625; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=sj4/1zOXXUNqP2YBqExNKT9kqAWy67bgeTiSkUWpqNQ=; b=Gp63mWWo8TPQaw4vsTSRSx6Bh+WENiEMRYcmVUSqofP1l8GaTBeWgLH6VoI/oKAlfm YLL0WR5W7xIaxxSDbpCS8CI6FkQzTtvpi8XGB4ruevU+brgVMj2EvTABYaZ5DReOsjzb FmLFBM5CicEg3Q8fdS4a/5sHM2F0C9S+l7JO9d1vqgxeLVzqs/FtyiBVVbV5829KlBJE 4dP9n99dsyzJ3+YThFKClr0CcrExI2sqHUugx9Fj3ve6waohxeU3DxLlp3YFaS1scgCU 9sjzzk2qTfL8MkkrkmMV1mIyV5Pb5/euWnpq4e9/m9nJME7aaKm8oxcg+24sgKpHdaLC +4Ow== X-Forwarded-Encrypted: i=1; AFNElJ/ACXO0lfTkZe5GpJUsbcFEqPyEeitEyl1R/CXfcQHSvWUOT6BzW/plqdPuE4LG9khhG7w897lwrfNexoE=@vger.kernel.org X-Gm-Message-State: AOJu0YyPYJTbNkCr0CahMp6L9GDY6IAPjAjwJu5U/SRksXrZedOAwaSN rzLSHKKSqAognDifH6txhCzG0HWbnmIW92689fZNwis/yxczid1y3Egt X-Gm-Gg: Acq92OHKpSOkQo1yciLDiTwjso0yp6NV75o6W9j4gGEiIOC3csMZGgAGCtrwbX+K/sK Eq5dqx8R8Gs6Ypl5k0r+WfWHpxctcDEz1ZevKmhwRJ25Ksj0VoO+HCQUkC6ogHZUQQ9rZ3Q/LHP Q/CieyLvi3pBLPl2DmJupwaLNQ7g7FUmf6upzlfjhpqyQG+9xaHheeQM1XOPw/6u7vp9osDms8u dfPidkWO5pwfkhyD8gS7s8DiDixM/X+1BI0klFYTUlMvhylojFh9HZWv0pd9Qsc/1m4/gLBSakL ncnp04NqFPE3QlYvjjtKTgy2tl7521jd4XZnOt3/heyeB+HxImVjyrYHCf5ZK/QXhxDMNlO1VUp DHZd8YzLceWqUaABbt+xdFPDo3UbE+CUi/F+rxAd3DYUge9DA+4xfU4SyonNLg50cInxAv3JQrv W9tJvMd8YbkBY86lc1U5uzrg5dXaDuEafXYg== X-Received: by 2002:a05:7301:e27:b0:304:ccdd:594a with SMTP id 5a478bee46e88-30ba596d4b3mr1992216eec.5.1781608824719; Tue, 16 Jun 2026 04:20:24 -0700 (PDT) Received: from osman.mioffice.cn ([43.224.245.178]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3081ea4f7a0sm17128752eec.24.2026.06.16.04.20.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2026 04:20:24 -0700 (PDT) From: Zhan Xusheng X-Google-Original-From: Zhan Xusheng To: Thomas Gleixner Cc: Anna-Maria Behnsen , Frederic Weisbecker , Ingo Molnar , linux-kernel@vger.kernel.org, Zhan Xusheng Subject: [PATCH] posix-cpu-timers: use u64 multiplication in update_rlimit_cpu() Date: Tue, 16 Jun 2026 19:20:17 +0800 Message-ID: <20260616112017.1681372-1-zhanxusheng@xiaomi.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit update_rlimit_cpu() converts the RLIMIT_CPU value to nanoseconds with u64 nsecs = rlim_new * NSEC_PER_SEC; On 32-bit kernels both rlim_new (unsigned long) and NSEC_PER_SEC (1000000000L) are 32-bit, so the multiplication is performed in unsigned long and truncated for rlim_new > 4 before being widened to u64. The same file already casts to u64 for the matching computation in check_process_timers(): u64 softns = (u64)soft * NSEC_PER_SEC; As a result, the truncated value is installed into the CPUCLOCK_PROF expiry cache (nextevt), causing the process CPU timer to be programmed to fire prematurely for any RLIMIT_CPU soft limit >= 5 seconds. The actual SIGXCPU/SIGKILL decision in check_process_timers() already casts to u64 and is therefore correct, so limit enforcement is not broken; only the expiry-cache programming is wrong. Apply the same cast here so both paths convert rlim_cur identically. 64-bit kernels are unaffected. Fixes: 858cf3a8c599 ("timers/itimer: Convert internal cputime_t units to nsec") Signed-off-by: Zhan Xusheng --- kernel/time/posix-cpu-timers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c index 74775b94d11b..5e633d8750d1 100644 --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -41,7 +41,7 @@ void posix_cputimers_group_init(struct posix_cputimers *pct, u64 cpu_limit) */ int update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new) { - u64 nsecs = rlim_new * NSEC_PER_SEC; + u64 nsecs = (u64)rlim_new * NSEC_PER_SEC; unsigned long irq_fl; if (!lock_task_sighand(task, &irq_fl)) -- 2.43.0