Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1908045pxb; Mon, 13 Sep 2021 07:58:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdlNVS3LHfKPvlI4AHUJvxBUG5OG1rzB9F5rsHNu5/ej6N9CArVucoyIZFtSFM3YJTP+6/ X-Received: by 2002:aa7:c7cb:: with SMTP id o11mr13621133eds.137.1631545100558; Mon, 13 Sep 2021 07:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631545100; cv=none; d=google.com; s=arc-20160816; b=LmvKslCpgnyTiu8THvrfX0ZIwG6lqINxUpPk6F5b/yPNrucS1c11XP7O0BfzddelH6 GmajMM8dqF0byRDZHChrxXzaT6VIcYpSbcKKVrVqJV4k6Nu1gSi3IaS0MOFlyKMz07tT 1MssyPMzlPhoO+88utAjgXal1cdwp2A1YBjQCPd4I+zJbs4Cob3cbzp8mTZ+z6pWYw0o ED6xgOe1Xe6huSJmFUPw9iN6XieJvxsVK5/x8+innUnixokvdEerx7Sel9zJUS0fVAVe QB7J2v6sXZDKA7MWbiiybx021EO5I5vKBaUWgAud/OV1WuRMXEsTwtB1zjNDbv5yKSxH 5I1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=da6gfAo94Bx2qPARPZ4YxGJVtUy1tnB8Cu9aCDGOchY=; b=IIyD3edwEh2OAUmiVH88h359rv4QbOfWvjPRnkpPYVGLK8ehygRLCxTzJBKDRDEH5a hcfE9pQQHJhcHp8PVj7R/KpJiNEIbVCCVm67RyS0t+6PHoKz8XfRZ43lSmB4RvBwMOQo kQfpV+He49zrKF8jXin5OdhOokg/iSGon7Du2VIndhsjLlZjnjVVbv6JFKB8IHSFtw01 2DG154Fnr//zcDNeJSUZW1LV5nfdbQ+VUFeu6dSazp0pgJ8QROfhyy/f2c+34ixxo2nu nssx2kBTKauflnDXUoHrmxxYxMAkWumcevkfVN9G+cELTPefLMueL3cNx9ni9N8IyMfr 9ing== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ot7U21ZN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b17si7071438ede.497.2021.09.13.07.57.56; Mon, 13 Sep 2021 07:58:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ot7U21ZN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345272AbhIMO4w (ORCPT + 99 others); Mon, 13 Sep 2021 10:56:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:35086 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348581AbhIMOyx (ORCPT ); Mon, 13 Sep 2021 10:54:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E3E9160F4C; Mon, 13 Sep 2021 14:53:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631544817; bh=p8UufsOAlWSGbHBx1QuHSYNdlIZ1/cc8QdkENxgjmzE=; h=From:To:Cc:Subject:Date:From; b=ot7U21ZNxcCOzhT7OMtmxg0NwBx6P6ES6edjWR6z4khq9r01VQU3PYKEaAFt7geYM ay4sc20A94Y4g7u9wluzEJJ7EwiNTv+f1bGn2Tx/6MvlBU7aJUtZSSMgD16X4OHkue 5D4Jitr4iNBKMIgj3t/6mF4tfN+OFkikd7Evxsb8OLJkpCNZfrhXyjnPodpYXOEyuO 2vaheca3GSTGTXNxQ4l9LJVcRKY8tY9DEeyteZKZ7ZLyBjCfiUKZ3x6T6foXc+98A6 doQLPWO74CanJ5aco3whgqLLGpJWvk0UCNAApLti84jVqiYwqfTYYUBN7Gno9X+B/k ckmIfrM4kFqzQ== From: Frederic Weisbecker To: Thomas Gleixner Cc: LKML , Frederic Weisbecker , Victor Stinner , Peter Zijlstra Subject: [PATCH] posix-cpu-timers: Fix spuriously armed 0-value itimer Date: Mon, 13 Sep 2021 16:53:32 +0200 Message-Id: <20210913145332.232023-1-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Resetting/stopping an itimer eventually leads to it being reprogrammed with an actual "0" value. As a result the itimer expires on the next tick, triggering an unexpected signal. To fix this, make sure that struct signal_struct::it[CPUCLOCK_PROF/VIRT]::expires is set to 0 when setitimer() passes a 0 it_value, indicating that the timer must stop. Reported-by: Victor Stinner Fixes: 406dd42bd1ba ("posix-cpu-timers: Force next expiration recalc after itimer reset") Signed-off-by: Frederic Weisbecker Cc: Peter Zijlstra (Intel) --- kernel/time/posix-cpu-timers.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c index ee736861b18f..643d412ac623 100644 --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -1404,7 +1404,8 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clkid, } } - *newval += now; + if (*newval) + *newval += now; } /* -- 2.25.1