From patchwork Tue Jul 16 22:41:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kir Kolyshkin X-Patchwork-Id: 1961345 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=FzDguTpf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WNvFq0Xbnz1ySl for ; Wed, 17 Jul 2024 08:42:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 27C23384772B for ; Tue, 16 Jul 2024 22:42:05 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by sourceware.org (Postfix) with ESMTPS id 25D083858C56 for ; Tue, 16 Jul 2024 22:41:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 25D083858C56 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 25D083858C56 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::82a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721169708; cv=none; b=oAcAsl94X6xfs29vdPXehh3SbYNXh09eRdGao2wEm6yUKcFygfdbOnKuYNIWYYpmLeO+OGPr+ziazhOhyjf+RuOF6q/Vo2BzAfuV7Use0rihOGc3DPv67/OubmQcXu6Z4zgUUlmNfJoKhiHulpXy+CFSExFhw+mT9O1stYZKLp8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721169708; c=relaxed/simple; bh=HjZt3KbLxyt2FWnmlKB2hBPCntfhM+zDGOS6pnoN/QU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=O9hUgB9gWsfgXaohC0ClKKO1SslOol2nXkfCF9fPrcGven7BnVuc5TY1o4YSGOe/Xdi6O6SeAXl4dSxlbO3BfebtcOMC75Vdqtr98nYh+HNYpqb/ScSpMJI4EaChF4C1WKb09RxOxbkzgASGy/FgPqyAKrloDw4bEUkYcMjHrdU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-qt1-x82a.google.com with SMTP id d75a77b69052e-447e2d719afso2042871cf.0 for ; Tue, 16 Jul 2024 15:41:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721169705; x=1721774505; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=s7M9dMMyHXb1b+6FfrrKJ8uAnQkKyD2LxHKSi3ecF04=; b=FzDguTpfLh65IbHlQwfT0Hr57wzEDaXCF2uSH02qyV3YiPweqCsFooXxVVc5hDJeST M8GTsUaGfGxU66iU6daZ3+tRAfIl0YF6a5efMphs64OLq55Av7sTvzrL/ivjLsKIK9bg G7h8AXpwAWo7R2PTOukgd0+zS84BduW8fVRwpyPy5+bAN+3VzK22PJsBUKc2Rj/Y3XqU NRHvpL/Ewii8qC6tIc6xv81usVeISavl6JRDoLqIxCCNGxX5WWw8B4MBkYvyLe8FKRVl jc3mhb2FBNnDCv8DmsUKRFInlkx5kCZIBjtTwB9f4eAF1Jtuz/r4U/hH2sD9jdqAjOfH fHeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721169705; x=1721774505; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=s7M9dMMyHXb1b+6FfrrKJ8uAnQkKyD2LxHKSi3ecF04=; b=ebSTS+Fbz3RcwGuVU2i7cMERfDNcXGHH6W4NP5LGYn32E/vY4dfvAmt9pdh42wB/9z ng537DBqw6OEMTI6wo6ehfUP3/DRlSRGaT39tAvBTiT0aGLgHWriJYmUkHlLa9NjOj98 f02rPui1FLdWRZvFXOiboO+GV7EeB2+SzTLenWkNxoY2K+WPFIwD9Wp6dSHVKuX3tdYh Cx0fRXccbg+P9G1tWXKya5iCB2a3Av8uKQCt3iQI4BBxEz3Wl5KDTVqbck5faq1a+hu1 G0CicYcso69HvHpQVieshlQsF3uUqD7AbLaZT1p7/wIOiH25GXdR6JxsZJcNjqceVXit TTHg== X-Gm-Message-State: AOJu0YzEHoIaEOcH3U5czmhHJf/HOR8+W1CgwvIEKpR5c3vEt4apM/1P 0gl8xvNq5qlFgzwosy0b0SgEiA3ElHkAOlZTG6c0XN8yWBqWE2lRF+/Dyg== X-Google-Smtp-Source: AGHT+IGiuBoXRrGjGU7VffD3lxL27Uti5W7Zn2iRmtJ+4i/y5XetQIfSfNyeaAPCVV2BcNOwOmB83A== X-Received: by 2002:ac8:5e0a:0:b0:447:f657:8a38 with SMTP id d75a77b69052e-44f7ca8bbbamr45302281cf.32.1721169704861; Tue, 16 Jul 2024 15:41:44 -0700 (PDT) Received: from kir-tp1.redhat.com (c-67-160-124-188.hsd1.wa.comcast.net. [67.160.124.188]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44f5b7c3fe7sm39716301cf.11.2024.07.16.15.41.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 15:41:44 -0700 (PDT) From: Kir Kolyshkin To: libc-alpha@sourceware.org Cc: Kir Kolyshkin Subject: [PATCH 1/2] linux: fix/improve clone_args description Date: Tue, 16 Jul 2024 15:41:35 -0700 Message-ID: <20240716224136.784105-1-kolyshkin@gmail.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org Fixes: - pidfd type is *int (as it's a file descriptor), not pid_t; - parent_tid type is *pid_t (as it's a TID), not int. While at it, describe which flags are needed to be set to use some of these fields. Fixes: d8ea0d0168 ("Add an internal wrapper for clone, clone2 and clone3") Signed-off-by: Kir Kolyshkin --- sysdeps/unix/sysv/linux/clone3.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sysdeps/unix/sysv/linux/clone3.h b/sysdeps/unix/sysv/linux/clone3.h index deff63da2a..d097ed7502 100644 --- a/sysdeps/unix/sysv/linux/clone3.h +++ b/sysdeps/unix/sysv/linux/clone3.h @@ -41,25 +41,28 @@ struct clone_args { /* Flags bit mask. */ __aligned_uint64_t flags; - /* Where to store PID file descriptor (pid_t *). */ + /* Where to store PID file descriptor (int *). Needs CLONE_PIDFD flag set. */ __aligned_uint64_t pidfd; - /* Where to store child TID, in child's memory (pid_t *). */ + /* Where to store child TID, in child's memory (pid_t *). + * Needs CLONE_CHILD_SETTID flag set. */ __aligned_uint64_t child_tid; - /* Where to store child TID, in parent's memory (int *). */ + /* Where to store child TID, in parent's memory (pid_t *). + * Needs CLONE_PARENT_SETTID flag set. */ __aligned_uint64_t parent_tid; - /* Signal to deliver to parent on child termination */ + /* Signal to deliver to parent on child termination. */ __aligned_uint64_t exit_signal; /* The lowest address of stack. */ __aligned_uint64_t stack; /* Size of stack. */ __aligned_uint64_t stack_size; - /* Location of new TLS. */ + /* Location of new TLS. Needs CLONE_SETTLS flag set. */ __aligned_uint64_t tls; /* Pointer to a pid_t array (since Linux 5.5). */ __aligned_uint64_t set_tid; /* Number of elements in set_tid (since Linux 5.5). */ __aligned_uint64_t set_tid_size; - /* File descriptor for target cgroup of child (since Linux 5.7). */ + /* File descriptor for target cgroup of child (since Linux 5.7). + * Needs CLONE_INTO_CGROUP flag set. */ __aligned_uint64_t cgroup; }; From patchwork Tue Jul 16 22:41:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kir Kolyshkin X-Patchwork-Id: 1961346 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=ON/dE7b7; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WNvFq1W1Cz20B2 for ; Wed, 17 Jul 2024 08:42:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C250A384A05C for ; Tue, 16 Jul 2024 22:42:04 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by sourceware.org (Postfix) with ESMTPS id 348573858C78 for ; Tue, 16 Jul 2024 22:41:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 348573858C78 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 348573858C78 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::831 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721169708; cv=none; b=Qkgei2Nwq8vCUTEacAnn2anr0OC1TT/jmqZeqNROXqGmfLRGCmUjFiPeNEEItW+TRBkmvHQJgvsZ0NJhAHqsgjoYiXr/XQHXazcDAvKLop3gSPlyl7IdzUKAqeXcP7DGJgScDfJffIxsDaOdlT1KBpn/1riz2cYYno9dauGBsuQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721169708; c=relaxed/simple; bh=U26FkM+7P59eS5FaRiz3ubCD8S5WR4odcxPT/jHT33o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ASToXWVJoFX+VWTL1DK3ZGNoNCHG4KihFUFj3kO7yqFsjAdlyoLiXtlSOtIaZKmnY5vM8qK+maUf516uJA31/zOGorKUw7cPyFNfB+PUKfAmJzh0JyU43r4l1FtBG7QPFmjsUCG5n5W+LGlxn+BWEXEmVabcvezHaikY3xTZAiM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-qt1-x831.google.com with SMTP id d75a77b69052e-44f5df38e64so22808121cf.3 for ; Tue, 16 Jul 2024 15:41:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721169706; x=1721774506; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KfUC7l3/MyHz7oqUfTDTLgYTW2zaboRW807oPWb3Luc=; b=ON/dE7b7qCrl6/+al8Q977CxvWj++S/M1309piNQXZVh17XXmE4K0nM+9Lm86u1atX 580HrsN0OAFfH/+mEyvf71/upZ719vXdN1omT2SYdWRIKfZx2NjIG+q1ULct28uhNHYC vACY+WQs1y7cR66LC1UZxzMdUR4u5I3rB6r3IO9hYBCS9zm+/1irXXm6dO0/S0fwx+sW +QPpVJtkSnqse4KyC7wjJv1FOlO0ZLYox/GxhXXD5xqbSox5JtIgUFC6FUgV8oa95qBY wGk2AqJg+818QthnesSLopVT3SoH7mk/lp+ut1zUwRBL6IEAoYC7AkyK9GdB9UHQkfwk dt6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721169706; x=1721774506; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KfUC7l3/MyHz7oqUfTDTLgYTW2zaboRW807oPWb3Luc=; b=e/saBx5yDIa53+ySXfoj9xIlPfbaczXLwfrgVrgV3OVfVrn6+/nVTuok9d3gXygNSv TMQVm2iiRfdITDGR1mzcNAPEFK9TjaseoemPPdh+NhQIcrue/eqBXxNPu/fFETSAbd2A dXpDsjy0vxiTfwRzpnhiqAnyILw0Mtb9JPcIXyhpIqco36C/jL2JWK9sdDSKEKHove16 HptgoowKBs36CHk6TsEqpu7WaW+HfXW+4P+4HaZIkQEV0sYW12FC3TbLQ9xTaWUgybYq pTIZ4xOtq4Ft8UeS9nA6RYTPXByA8Da6qmehEdpDlCPBvCf1Za3mrNPXUfEXHFqc/oc8 jlgg== X-Gm-Message-State: AOJu0Yx/HA2R2m40Gs0mSKA4VYc1pHBoG8z/efZBX3+u+hX8t+/0BW4K 1QgUv8zQZ+mVK0/FR7Obzw2PE81Ky5r4Q+7i8uU6e7aWN63PSs6hoZ+xvg== X-Google-Smtp-Source: AGHT+IGyLtIoIBYSpABnSLtN2fZKvXRz/yOmvduezI7sB35uHIJySAJSdu9+C2nGrPYCA+KS5yigzA== X-Received: by 2002:a05:622a:305:b0:447:ef14:7c09 with SMTP id d75a77b69052e-44f7abc6012mr40857701cf.6.1721169706153; Tue, 16 Jul 2024 15:41:46 -0700 (PDT) Received: from kir-tp1.redhat.com (c-67-160-124-188.hsd1.wa.comcast.net. [67.160.124.188]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44f5b7c3fe7sm39716301cf.11.2024.07.16.15.41.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 15:41:45 -0700 (PDT) From: Kir Kolyshkin To: libc-alpha@sourceware.org Cc: Kir Kolyshkin Subject: [PATCH 2/2] nptl: don't set pidfd in create_thread() Date: Tue, 16 Jul 2024 15:41:36 -0700 Message-ID: <20240716224136.784105-2-kolyshkin@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240716224136.784105-1-kolyshkin@gmail.com> References: <20240716224136.784105-1-kolyshkin@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org The pidfd field is not used in clone3 syscall (or its glibc wrapper) unless CLONE_PIDFD flag is set. As we don't set CLONE_PIDFD flag here, it makes no sense to initialize pidfd field. This patch doesn't fix anything, the aim is make the code more readable. Signed-off-by: Kir Kolyshkin --- nptl/pthread_create.c | 1 - 1 file changed, 1 deletion(-) diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 1d3665d5ed..616afb8baa 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -287,7 +287,6 @@ static int create_thread (struct pthread *pd, const struct pthread_attr *attr, struct clone_args args = { .flags = clone_flags, - .pidfd = (uintptr_t) &pd->tid, .parent_tid = (uintptr_t) &pd->tid, .child_tid = (uintptr_t) &pd->tid, .stack = (uintptr_t) stackaddr,