Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1394169lqp; Mon, 15 Apr 2024 05:31:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVC7dzALthRVbz821OEcAu5dJTfhUULVzObQj53Pgpf0M8fCJgNkd2jEIfdC9uKp2SMu2xUQH2FZheSwuYs/PkcioEeEojnry4jQqOx4w== X-Google-Smtp-Source: AGHT+IG1bhbjTaqz7TD+g5ymbR90ilx44k/81gkrBldtKhuU9+1JCVWf2MISo3ROpV/PPbefIcxd X-Received: by 2002:a17:906:d159:b0:a51:d19c:aba8 with SMTP id br25-20020a170906d15900b00a51d19caba8mr5857123ejb.20.1713184279957; Mon, 15 Apr 2024 05:31:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713184279; cv=pass; d=google.com; s=arc-20160816; b=ORnsZc+e6el5jtVI6BNP8Vz2aj5ThEHNYRl3tuJOwlO0rNW0Boh0qC26wAhpZEQ//J aQ5fDjZ9RvGK+aWScO26I8umEKO/hDk7qK8AFIcF+sEVVwjfsNPNjQQaGdc+m7wx9Lq8 LTMXcxwpcMdUmlIY/NGSsUjkEyoJksK7+6OW3rG3oqvnMLqNTYDTOBFOcqRmfp8um9pS JZSUq5rLFfBQDKSTBLq5qrNKh3GaOxLelMBtE/OD9NukZExIZYnTaPuzl9YMQo3F8TIT M21FRH6WkF9H2HMTK62SyqB1ZYgCj3dEp6d17JKwxuWUu81nIf1uFIOmBf77pIABD2EM oA+A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=31UKcuC29fhH2gQ7AFdErWb9xDpB3f6MYdu5CdzUIIQ=; fh=MxOqrKe8Fax3kxE77rA0inxVaQwZCyEyqDk4Qwcbk14=; b=VP93BItlNHUJuoryn+r+qYR7ZGa5lzTgTizJB9AD4QMpg6YHyXZsKWq7Px1BkVPxho YU3RUpatTka1md7z8GoYKOM1vvNAI0jqHmW6S+UbFcw3JG0GXvGIOv9v584Dssf3XEpl wNx/YBIN3oxzFvJ7L6a8wyu4oFFaDAEm03fyEjw/P64V5IzFgZPIx2V/9/+QW1tedtZa 9WAc+qGx15w25P4czOMxPSW39eFkDoOLMKVgIqEbYE+GrHGy5smiwY0h4FY16vi8Yw7w NlujhQaKS0WG35MEkKKABoBLeZfZFkw0HjFltj7h5ghGdC1i2UBR2O17MScl9Z7NpOB6 IJvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=IA2k3c0V; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=TUgzW5rl; 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-145069-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145069-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ji5-20020a170907980500b00a51d3658a7asi4670847ejc.594.2024.04.15.05.31.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 05:31:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145069-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=IA2k3c0V; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=TUgzW5rl; 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-145069-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145069-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 am.mirrors.kernel.org (Postfix) with ESMTPS id B00E51F21CC4 for ; Mon, 15 Apr 2024 12:31:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 703356D1A3; Mon, 15 Apr 2024 12:30:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="IA2k3c0V"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="TUgzW5rl" 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 4D9081FA1 for ; Mon, 15 Apr 2024 12:30:54 +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=1713184256; cv=none; b=Gyf1Rst6XJFxK1RQl+eBXGMgb//L1juXY+Ab7cAIQoywQwk7VMqpkHB8h/MY7Yy5cud6t6OePP0gLgYAXDtJipFi0f5jvAcWXwo1wJ+d87PVFw3KvXGkIGSwn2h7mFR6+HwOlP45fRjvsLD5f+AqRZ/D9e3yHb5KZjww7Ewz/Zs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713184256; c=relaxed/simple; bh=16igbDBxYxvU1x661QKxvfTSCMQD0ch6OYA44oQy3vM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=CaiiWqwgwhsuXLmw7m2nxoNJIy3SygCUY/Tgg6KAMJROMobZ6OKFl9uM9ALPaXP1pBguJSeIW+TvSgVcVuL1olZ+CfW4PQVu44TysYxYEOT0Ou1FLq/ruXo0mcYIIF17BDWBvMi0+6sORxNAEUOtj9pd44TBtRl/iuG7LjLEM3M= 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=IA2k3c0V; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=TUgzW5rl; 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 From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1713184246; 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: in-reply-to:in-reply-to:references:references; bh=31UKcuC29fhH2gQ7AFdErWb9xDpB3f6MYdu5CdzUIIQ=; b=IA2k3c0VmYV/3qlHKG/q0IL16+qVecLW1kmkRnzkF8ZJQyMSpEQHQ03AhC+Qrf1qersnMn OjmfGotp7DvX/pNtpnTxEqe0380WqVjMynm/cZit7Arlx3x4TlJP/BxcJxtKp8qr36bBgc fPV/88gmDf3HBPqCmi0KZEYUYVvV0FicAHPTpDUyqsTDGXUCSZVB2G6bqekpvOmZKT0FII 0Q8mHybMXof9/JkcsB5ULGYMPreJwUDblsZebPW4V+2kRZGdDh1VqNgblUb0d6WagCLrSu hpoFiiCXUn5dbOgiU8jDGWqlpCofehUb/Jm2h7cYY5aUe2McPU6PZ25WSa4dHA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1713184246; 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: in-reply-to:in-reply-to:references:references; bh=31UKcuC29fhH2gQ7AFdErWb9xDpB3f6MYdu5CdzUIIQ=; b=TUgzW5rlPcFwUnHGWaqJx1OzgGk/iRrOD4lh6AyUxW9TXvku79JXSZ64ChEDnt8EhUMXW3 4RYcrrpU6vkFVZAQ== To: Thomas Gleixner , LKML Cc: Frederic Weisbecker , John Stultz , Peter Zijlstra , Ingo Molnar , Stephen Boyd , Eric Biederman , Oleg Nesterov Subject: [PATCH] posix-timers: Handle returned errors poperly in [i]timer_delete() In-Reply-To: <20240410164558.316665885@linutronix.de> References: <20240410164558.316665885@linutronix.de> Date: Mon, 15 Apr 2024 14:30:46 +0200 Message-ID: <8734rm95ah.fsf@somnus> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain timer_delete_hook() returns -EINVAL when the clock or the timer_del callback of the clock does not exist. This return value is not handled by the callsites timer_delete() and itimer_delete(). Therefore add proper error handling. Signed-off-by: Anna-Maria Behnsen --- When having a look at the posix timer code during reviewing the queue, I stumbled over this inconsitency. Maybe you want to have it in your cleanup queue. Patch applies on top of your queue. kernel/time/posix-timers.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -1009,6 +1009,7 @@ SYSCALL_DEFINE1(timer_delete, timer_t, t { struct k_itimer *timer; unsigned long flags; + int ret; timer = lock_timer(timer_id, &flags); @@ -1019,7 +1020,11 @@ SYSCALL_DEFINE1(timer_delete, timer_t, t /* Prevent signal delivery and rearming. */ timer->it_signal_seq++; - if (unlikely(timer_delete_hook(timer) == TIMER_RETRY)) { + ret = timer_delete_hook(timer); + if (ret < 0) + return ret; + + if (unlikely(ret == TIMER_RETRY)) { /* Unlocks and relocks the timer if it still exists */ timer = timer_wait_running(timer, &flags); goto retry_delete; @@ -1047,6 +1052,7 @@ SYSCALL_DEFINE1(timer_delete, timer_t, t static void itimer_delete(struct k_itimer *timer) { unsigned long flags; + int ret; /* * irqsave is required to make timer_wait_running() work. @@ -1054,13 +1060,17 @@ static void itimer_delete(struct k_itime spin_lock_irqsave(&timer->it_lock, flags); retry_delete: + ret = timer_delete_hook(timer); + if (WARN_ON_ONCE(ret < 0)) + return; + /* * Even if the timer is not longer accessible from other tasks * it still might be armed and queued in the underlying timer * mechanism. Worse, that timer mechanism might run the expiry * function concurrently. */ - if (timer_delete_hook(timer) == TIMER_RETRY) { + if (ret == TIMER_RETRY) { /* * Timer is expired concurrently, prevent livelocks * and pointless spinning on RT.