Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5757457rwd; Mon, 5 Jun 2023 08:10:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4/NYMRIj0oz8EkbPEY2YPm7n42khUDzYZ+Pj/2Mphqa34nPWyMTCTgOXipU8ViEt0guQ6f X-Received: by 2002:a05:6a20:a481:b0:112:5404:88cd with SMTP id y1-20020a056a20a48100b00112540488cdmr1945510pzk.60.1685977825773; Mon, 05 Jun 2023 08:10:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685977825; cv=none; d=google.com; s=arc-20160816; b=EEK7lCsfo9o5Ir4TiTg0W0Sl/ptZPiP5QdDyqlVd4dk0howwL0aDTg0FXfkBu2lbcS 4iknMa0lcCijWV2ZoJCOMN5eXsrKVyNopqLimdKRBgjbU2cmnBhNP3jbOC+xq4EaQHKV 60QQ2VGk6VXhBG4l2bC6zo/KXIkaocPuE58h/34z+ep8gJmj7h6pUYgxj0YOEJoAGi/4 y2sEr/fcVXaAzKNOjXhmyB/iK8ttduYO0JkvOEILbwJ59edtjk46Q1a0qwdYifvw0FGj tBuHj3Jo/wBWmijfCiZ8UNzOyPsoTy8CHSj3cHLb214sX0RGCM7wlXosSM3etIGEEA2n wpng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=1bD6hLaUNRAo6XBj38rT/tzr/rKMzfyvrpIv8NDmkAQ=; b=cLPvsvWfF87mkFCezJZGeVZV//5R+ce/K/ODkiTMRvyEWsFBGs7FvN76RNNBS2Tp9i iKus0Gb8QcRRpNz6b1Cy+tqYqAhtGI20IlCc2p281kK9VZkJQXA/2PeXfwBPg7+BpF1I AOY7WGSTvqnVbXvmyiZHoJR/nwjgfNks7K/yYkfE/lsKmXYF3LyVufKASiZLpwL/YqDr 2kkFTTsF8tP66ZaBTzZC5ftNw8clMeeyndpZR0iil5LZuLKhDS6Bj+ef0omTaoh6R5hB 16Y6EmspmePYspL8Bt0a9qUnrkNsGuulsJO5Ksk5XHf1d7Qd40rSeD3/9DVFCJ5jYMOG H82Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Qa/nnTL1"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a190-20020a6390c7000000b0053f26705a25si5637081pge.321.2023.06.05.08.09.51; Mon, 05 Jun 2023 08:10:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Qa/nnTL1"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234549AbjFEPIy (ORCPT + 99 others); Mon, 5 Jun 2023 11:08:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234035AbjFEPIa (ORCPT ); Mon, 5 Jun 2023 11:08:30 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40947F1; Mon, 5 Jun 2023 08:08:29 -0700 (PDT) Date: Mon, 05 Jun 2023 15:08:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1685977707; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1bD6hLaUNRAo6XBj38rT/tzr/rKMzfyvrpIv8NDmkAQ=; b=Qa/nnTL1rnED6pRwSjRBbbDUMxv0UABQ4OCyzjnT/s7br7h/07wVy1Lu13fKOZS5wSxH1F S4eeRnQk99PCFBCAmoKf/qAInLBmo+FVhC8PBhGYzkt5LG5fK6Y2ZPWK8oLRvw+Dk8e7QV 9/tNalwFlyZWeXinMgCkleLMNrHpSmLj130EPPf2iilbWpmvc1/zXyU9qUOfh6wXDA49WM pU+F1Jwq0dh9uJJ00TeDe01SPh6M19Q3Iw6Z63gnQWnMaXV6EAXB2qlSGM7uWwQbQYCVWv 8baDJNO2q02ipXvNSpscQMQhhAWfpX7CYgeoCDDrLjV84F/u2Xe0DOuM0lTl6Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1685977707; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1bD6hLaUNRAo6XBj38rT/tzr/rKMzfyvrpIv8NDmkAQ=; b=APu5y6d+n+E3VUuCXXTRxfQJZekXPKqbAthBCQjRJ/HHugOfA51USnRIR6eZE5qeNqcL4P yELLmGXy9wSvUZCQ== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] posix-timers: Add proper comments in do_timer_create() Cc: Thomas Gleixner , Frederic Weisbecker , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230425183313.619897296@linutronix.de> References: <20230425183313.619897296@linutronix.de> MIME-Version: 1.0 Message-ID: <168597770743.404.16840396422526470034.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the timers/core branch of tip: Commit-ID: 2ef6cf6d46b462a1ff7fb70ad8050a2b35077e19 Gitweb: https://git.kernel.org/tip/2ef6cf6d46b462a1ff7fb70ad8050a2b35077e19 Author: Thomas Gleixner AuthorDate: Tue, 25 Apr 2023 20:49:19 +02:00 Committer: Thomas Gleixner CommitterDate: Mon, 05 Jun 2023 17:03:38 +02:00 posix-timers: Add proper comments in do_timer_create() The comment about timer lifetime at the end of the function is misplaced and uncomprehensible. Make it understandable and put it at the right place. Add a new comment about the visibility of the new timer ID to user space. Signed-off-by: Thomas Gleixner Reviewed-by: Frederic Weisbecker Link: https://lore.kernel.org/r/20230425183313.619897296@linutronix.de --- kernel/time/posix-timers.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 9ce13c9..5cfd09c 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -529,12 +529,17 @@ static int do_timer_create(clockid_t which_clock, struct sigevent *event, new_timer->sigq->info.si_tid = new_timer->it_id; new_timer->sigq->info.si_code = SI_TIMER; - if (copy_to_user(created_timer_id, - &new_timer_id, sizeof (new_timer_id))) { + if (copy_to_user(created_timer_id, &new_timer_id, sizeof (new_timer_id))) { error = -EFAULT; goto out; } - + /* + * After succesful copy out, the timer ID is visible to user space + * now but not yet valid because new_timer::signal is still NULL. + * + * Complete the initialization with the clock specific create + * callback. + */ error = kc->timer_create(new_timer); if (error) goto out; @@ -544,14 +549,11 @@ static int do_timer_create(clockid_t which_clock, struct sigevent *event, WRITE_ONCE(new_timer->it_signal, current->signal); list_add(&new_timer->list, ¤t->signal->posix_timers); spin_unlock_irq(¤t->sighand->siglock); - - return 0; /* - * In the case of the timer belonging to another task, after - * the task is unlocked, the timer is owned by the other task - * and may cease to exist at any time. Don't use or modify - * new_timer after the unlock call. + * After unlocking sighand::siglock @new_timer is subject to + * concurrent removal and cannot be touched anymore */ + return 0; out: posix_timer_unhash_and_free(new_timer); return error;