Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp486328lqp; Mon, 10 Jun 2024 09:49:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWDwcpi1NKhvMkeI0UM9xTHaR1nJBVYydybpp3wJaepmy8ihWPCaumDAzCXYdWb7M7AFoymc2IDSqnSlMaTPTWVh2bl5j/Y065EB8K7BQ== X-Google-Smtp-Source: AGHT+IGle9MEe0XYbOqOjIDemrIJIUL3jjL4ZlN3x7IKRhhoWiINPSQqdePDD35x9dzDS5R162QZ X-Received: by 2002:a05:6a21:c95:b0:1b7:4adb:1dce with SMTP id adf61e73a8af0-1b74adb1ea1mr4309301637.61.1718038187804; Mon, 10 Jun 2024 09:49:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718038187; cv=pass; d=google.com; s=arc-20160816; b=Oc0okupiYSAprGbL6CF1eHGm8M6KYHgDOz6ZVQigTRKk8v8/N/c8Mn0Z5ZAOtuA51f nMl0NK7buUxrJ+f060niMjMxpD12Qv0UhJYtnqJrlDjAIsS3Thqyt6039a9yXtulROx2 Id0t6KAL8KuzTQLxWiPVxezt9ye48/7LZCeQBfG+2w20uyECQVM7yP5KBkdc3RD+qTCi 8OxnZZ3q0ZTfM66XBw3moaYC9j9aWR2OkgZWfnh8rVz8lTNV+O4tRju0IOipPAM42VgK 1eWsnfUbw8V0KGzFkoXjB0g23KhnH4YL0r7VLyCsVCktoVVVG9Xs9T33KnDf3j2KVcIv vwJw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:subject:cc:to:from:dkim-signature :dkim-signature:message-id; bh=aNS2WvbMpSrKZ+gyfUquRBBrzhJQZEx4EROddFmkK80=; fh=joBs/8L+orz77ylyCy6wqNwwi35f7sYhLR+/TQjQjhI=; b=vdfGayLP7KkU35+mJGOOYZ0YLmdpSKQ7JwzDSb6LkkpNu2L7b8OpgnZcUdY9e2v8O+ zQAd3H/csGSOQOaf72mlKQ/TtLJxnJQcE8dxQu5kGVaybDbCoxTVu6zorqoOAGUN1H1j ZwHrOYag46F/oFxJ7XQ3B54CfgG3dZJV+hkx6psBPYzk+XsW3WnyLN3zdSiCFMDRLXPJ ezaSzEjW7s17NTnBpmiA8q7NHa8gLeYqnQQl3NAJsTMFD5prQCDV3EvXpgneDDAhcN1T 5w9u/01Eda8/2wg5QVMfIsBBoy/nbYTAlUpK6b7qZYe8sOd2JDrS8xuGvKxSuvJFgkSz pAUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=aaFg6+3c; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-208598-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208598-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c32c178050si363a91.133.2024.06.10.09.49.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 09:49:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208598-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=@linutronix.de header.s=2020 header.b=aaFg6+3c; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-208598-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208598-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 338A92820DA for ; Mon, 10 Jun 2024 16:49:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7584514A4FC; Mon, 10 Jun 2024 16:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="aaFg6+3c"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="+jMmRPvo" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 1AC60156F5C for ; Mon, 10 Jun 2024 16:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718037771; cv=none; b=Y3Ea2ayOw+Z1Wqpbe1sTAqLhwTYkHRxw/M9izYZsTTR7+2o+yBFzV5eD2YSQN9gZZFUd1WxvQxfqkEtErhOgTTOGVayZ2bZaAVH5BcWFqgIp3+8GTs4jjB0hxlU24Pz3D7+9igL4vrjKOodZndGRsUQFRH2Stmz33M9EjhhYK54= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718037771; c=relaxed/simple; bh=hYNVuSguWX5kL+feRx+7A+qZ1CJIoDAjlsCoswgjWkw=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=MQNV1LGBM2iIJ2cBXS+jUA73AjLIeTJ0PdzOehfsSH+tWh04av9jbpl/zdllwAFHPGwEt81NoSijcxXWE1CbltOJ5qRkAOmxbxoMmVlKW6u/zdmFINDl6AE0Rc/AERWnIp4yTLS/lcgmAeRCF4NaLHA9GqSQk3YEIphzhLhWsS0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=aaFg6+3c; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=+jMmRPvo; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Message-ID: <20240610164027.606874728@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1718037767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=aNS2WvbMpSrKZ+gyfUquRBBrzhJQZEx4EROddFmkK80=; b=aaFg6+3cICoZrAclQf9VXJb4U69oBHrt517hxlQObtG7pHFeIyQwjMrYeQ7/cL4PHOcBxm w0o+j8EH653Y41xDvCq0vkNOPUPsa89qG8ng4YnwUhVj0AS82yEW6JMuKUe0YNmRvy2GQ0 hDyi855Xq0EYXJjzgxnqAZeR3NLaF6MmG8j5sZl1DAaWL0DB2YrIXUCgOuSd/wOy7LSWNV jDKBosfYtbMhYNG1NofnOFccYhaKpKiJ5EbEKhjlfFqcB4kzTiiy+YOWmo8hXUVQuOFeBo ZaWWpXb30kk6Z5VI+EJ30J8rhdlSxNSL237ZsDetHVUqh1W0JY1LcAFggmZm5w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1718037767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=aNS2WvbMpSrKZ+gyfUquRBBrzhJQZEx4EROddFmkK80=; b=+jMmRPvoCmehn8UIzWW7nU2Oh+DDhDlNr3G6pXEyK017UnEX34UKLhH+BwxIQnDfzqqkmX i+cUSDSlc9vKwADA== From: Thomas Gleixner To: LKML Cc: Anna-Maria Behnsen , Frederic Weisbecker , John Stultz , Peter Zijlstra , Ingo Molnar , Stephen Boyd , Eric Biederman , Oleg Nesterov Subject: [patch V3 34/51] posix-timers: Make signal overrun accounting sensible References: <20240610163452.591699700@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Mon, 10 Jun 2024 18:42:47 +0200 (CEST) The handling of the timer overrun in the signal code is inconsistent as it takes previous overruns into account. This is just wrong as after the reprogramming of a timer the overrun count starts over from a clean state, i.e. 0. Make the accounting in send_sigqueue() consistent with that. Signed-off-by: Thomas Gleixner --- kernel/signal.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) --- a/kernel/signal.c +++ b/kernel/signal.c @@ -1965,6 +1965,34 @@ int send_sigqueue(struct sigqueue *q, st */ q->info.si_sys_private = si_private; + /* + * Set the overrun count to zero unconditionally. The posix timer + * code does not self rearm periodic timers. They are rearmed from + * dequeue_signal(). + * + * But there is a situation where @q is already enqueued: + * + * 1) timer_settime() + * arm_timer() + * 2) timer_expires() + * send_sigqueue(@q) + * enqueue(@q) + * 3) timer_settime() + * arm_timer() + * 4) timer_expires() + * send_sigqueue(@q) <- Observes @q already queued + * + * In this case incrementing si_overrun does not make sense because + * there is no relationship between timer_settime() #1 and #2. + * + * The POSIX specification is useful as always: "The effect of + * disarming or resetting a timer with pending expiration + * notifications is unspecified." + * + * Just do the sensible thing and reset the overrun. + */ + q->info.si_overrun = 0; + ret = 1; /* the signal is ignored */ result = TRACE_SIGNAL_IGNORED; if (!prepare_signal(sig, t, false)) @@ -1972,15 +2000,9 @@ int send_sigqueue(struct sigqueue *q, st ret = 0; if (unlikely(!list_empty(&q->list))) { - /* - * If an SI_TIMER entry is already queue just increment - * the overrun count. - */ - q->info.si_overrun++; result = TRACE_SIGNAL_ALREADY_PENDING; goto out; } - q->info.si_overrun = 0; signalfd_notify(t, sig); pending = (type != PIDTYPE_PID) ? &t->signal->shared_pending : &t->pending;