From patchwork Sun Jun 18 20:49:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 109665 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2634602vqr; Sun, 18 Jun 2023 13:51:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7R1RJsYM9D7Ubgn1h0pB7d+aU5MXIYQRRoJcWuYbMt0o35mxhcV0ce8eYPHEgMxwttuwyu X-Received: by 2002:a81:75d6:0:b0:561:4bc2:1587 with SMTP id q205-20020a8175d6000000b005614bc21587mr9226512ywc.39.1687121478816; Sun, 18 Jun 2023 13:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687121478; cv=none; d=google.com; s=arc-20160816; b=t4CjbrDZdTyn7V6wY45fZFA4S10u+WmFODeWrY7UgdFl1aG0FTt69KO0c6fT4l74RG j3VemtcsDQhgfNqbvMO+ORyMobLh1HT1HubjbPHcxRTP522nEe+5pfcfWLKV/bRrLTkW gEaN9tVmCol/wstfLsn08/XuCmtpgNVPsWRokPwtV4VtxZG+b20Z/V1vEB1NJZH/znti PmmDAXRmZqvN1r3tlFKH4ypQZCENx+Ex6Ip83BGkEWhbGKE1YJLYAgyIq2N5wsdyLYRi AmcIujvYkZU/F+E6t6a6AL104trFU3qm9VIDnI+9GhAN/fewNclxiZY4ky+sy6Lvrb9j PEkA== 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=S2grR4taeojETLKA4WB7/rLhdtfB3E8NAr9445/B/eU=; b=KJMvu4sxD3YKLDGnTMBJMTRWVLru+P3UaWY138WFIbj8vNr0vAymuHlwGR4Y4Bc98T Nw4CgL+FjHa7LKDzRzl2LuR9J1tQwhdWg2siYY22uJCJxd9c4A5iQm+TSFp4+nQtAAYA f2/geD3WXzvf5ggIfH4EMXg6W73M5CgJx5AXtO8IH4Al/c2SlOlGUdD7RWoJqRR/prwW Afn5iecDGQhbLRAgPI7THlGbf+1PMLXsrdcEGSFUvHPCs9/WN2veRboLxUYiP6alxzxe 89O8r3H/nZh32vH5caBm244Out/w1d6gVk3naZQc+2qTuqOkbIUxWISuc5vGGmo4eKOG Xefg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Ha5vnXTv; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v7-20020aa799c7000000b0064d419dd566si19429722pfi.205.2023.06.18.13.51.06; Sun, 18 Jun 2023 13:51:18 -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=Ha5vnXTv; 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 S229756AbjFRUu1 (ORCPT + 99 others); Sun, 18 Jun 2023 16:50:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229584AbjFRUuC (ORCPT ); Sun, 18 Jun 2023 16:50:02 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09AC5E4D; Sun, 18 Jun 2023 13:50:01 -0700 (PDT) Date: Sun, 18 Jun 2023 20:49:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1687121399; 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=S2grR4taeojETLKA4WB7/rLhdtfB3E8NAr9445/B/eU=; b=Ha5vnXTvzB2l57TwS5mO8LbrMe3VdI6vCKyERKehtNNz2byTLtp2Oe1VZihzbjHpkeA11x s3AUayRsHTJ+pfLXeme08pz+zo0ZBoqY410bZ2TsiOh8UsO7skMpi1Q6OF5KnM4q+oudXD bSYyAxWVOtvHBb5++Ppf0MTU42K8a3dMyqC1+US9KrSbcCT4htdHJcULtGLvFzRMCYXJqF Vey6emGhcZugTYOAvoNNAlP67iBYc9ikE+7kJ/YTUHICSsUsi0NUm890LokzCVBDL6kVvh hgL/NgWbXLJpdVUlUNjw5WCq9mlzGQF4kw2Qn4VkfeMFVXhKJv5V2T5Zs0d5NQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1687121399; 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=S2grR4taeojETLKA4WB7/rLhdtfB3E8NAr9445/B/eU=; b=zVXqQibN52woeXBIInlKZx9vYjmtOCkFA+9fgeqC6cMFySahMhoxNp5tfeK9E+qDchKNDs m0+ciI0jFyuoDMAA== 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: <168712139917.404.9575558212543207671.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764175797133736533?= X-GMAIL-MSGID: =?utf-8?q?1769075092081373367?= The following commit has been merged into the timers/core branch of tip: Commit-ID: 52f090b164b59c06a4da87c0599424809a6bba16 Gitweb: https://git.kernel.org/tip/52f090b164b59c06a4da87c0599424809a6bba16 Author: Thomas Gleixner AuthorDate: Tue, 25 Apr 2023 20:49:19 +02:00 Committer: Thomas Gleixner CommitterDate: Sun, 18 Jun 2023 22:41:51 +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 54adb4c..20d3b99 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;