Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1496059rdb; Sat, 10 Feb 2024 04:48:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHjKv4fU4W8fdMwUuT3LVbTFXiHFZOuXJE96+EWmtkZpU4CjjngT890XrW1+WzQoLqY4CUI X-Received: by 2002:a17:902:eb45:b0:1d9:c17b:43ff with SMTP id i5-20020a170902eb4500b001d9c17b43ffmr1958346pli.3.1707569319852; Sat, 10 Feb 2024 04:48:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707569319; cv=pass; d=google.com; s=arc-20160816; b=aFsK93k+r5E2CL9ZT1XuF2iG01gKTHQ8yz6t3uwZQxZhUIr4CzJKA8RniD8WM74Vag A89WSkLbRnISuR/DQ6BSDoqxSWFsQDJanJR+3PV5ma0nrti3a69w2HEeslJBDNIZKNNo msOYLQbIU2fLZpbd2DoEBLOp8xLh1ytrR6pg9SE7LU2gFPMEBjfFqNdmjRfnIrbK8aee 1j7juAG83B2lloxsePD/qWmYoY/tgaCC91mVle7fEoRBj04xl8X0RSQ7ED4xCVMj9MRp /soX0K5v8PSWuYxMS+PuS9bmps8iFVx/7QrvLfdaQJeWlbBcEivzyW4eDX0SS2itkyfk ueQA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=rEhCrduBe0d0dS/swjdcoc7IV7EN3jeoaehg+0ZcY7U=; fh=KMIzi11DD4H6aSioeHSlyo0tE4i8mqOrqnjw0zru0E4=; b=VInB0aVXuQo7Th/OSTeSa+Wj4vTlhk84HtCBMsNR3gtqqUUb9iBPbyhMPVG00urAUo Irgtmov2bkaX5hqupfgBDZEnyH437qmDGi29Kgb6+xcWQf2WjkO8LcF8eWb2nhlI0uV2 2QFuia3b1GzDxi2r5iYFX8fBZ6Gfpq2F8i8gA8CoSZXMVcma7Dg4w60Etee0o4pgB95T 7W9R+4gsdXzZLVRit7g1En+bdMALSrraBg0C9v1KXOEOx9bi7rBVm/lHXz4azKIot/Qc 7vjGtTvzCabf0LF7XuDBEGIOCIZTdMg9J8i+QIuL2e6YQQMsIyhCmMWoi54C4Wks7TFQ e95w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="XIc0E/vV"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-60402-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60402-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCUlVALaVi1NlvndGx4S0im8A69Pxlckx4OJZFaR0ndJ4P2zy9VEDU5CONBoGrC0iP89OHc/8uR+kENT6fWOCf4DIddRYIAqzoSzSRNwNw== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 21-20020a170902c25500b001d963d963a9si3316537plg.2.2024.02.10.04.48.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 04:48:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60402-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=@redhat.com header.s=mimecast20190719 header.b="XIc0E/vV"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-60402-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60402-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 779E4282CD2 for ; Sat, 10 Feb 2024 12:48:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ACD4A481A6; Sat, 10 Feb 2024 12:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XIc0E/vV" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 51E9147A7E for ; Sat, 10 Feb 2024 12:48:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707569313; cv=none; b=BxtpGUe3IBH8DSqtT4J6RLWi87n344NhPjzuvBvc19qdrea6PT+bmuV3sNlYv1WXgy0pJrea8HUT0CVUHgGt0/o+m6DEEKa6+4J8W1N4Jo/kVx7FJn4p5lJwNdziTbPOvVzQ53s8cvq8kzUSUvQpYHxbFMkhZ9yWyDQkTmTsU+o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707569313; c=relaxed/simple; bh=5ZCGE2D6BjdHZDF56ZZ2sS6U790ZU0GDo6OY3wAA4II=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QoW073VVjYcxnCzTzUVSpv8yTW2NXkBkPFhhMXqbmOyUORTtKRCUqEsPJv77OmMYHqeGQPsr0Rrkr3o7jmT6qsrtZuGZSUUhGy/gMYMiurDa7WcTKrIy1cnTH6Pr2tT+I1rWSBMrX21iatkPUG90pDrWqBqORyhPD8HPbzrZ4BY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=XIc0E/vV; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707569311; 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=rEhCrduBe0d0dS/swjdcoc7IV7EN3jeoaehg+0ZcY7U=; b=XIc0E/vVfTRMCl5O0cNWs/0iopceXxL5uWdMsLVZFrKy6mkH3Y3UCvAMFfxlzrlyCVi8vJ tRq57zpr9Acf4hmHung9xUmbnMR8juSvovdMPbSlMRNIBc4yCWAeefPkGYdHjIfNBwqorG VLbWpTQLMqDat7PK1BBEBiMVZdYIL+k= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-461-FBHrH_pdMsat5QBf9ecVqA-1; Sat, 10 Feb 2024 07:48:27 -0500 X-MC-Unique: FBHrH_pdMsat5QBf9ecVqA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 56419845DC0; Sat, 10 Feb 2024 12:48:08 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.224.28]) by smtp.corp.redhat.com (Postfix) with SMTP id 64580200B3BE; Sat, 10 Feb 2024 12:48:09 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Sat, 10 Feb 2024 13:47:10 +0100 (CET) Date: Sat, 10 Feb 2024 13:47:08 +0100 From: Oleg Nesterov To: Christian Brauner Cc: Andy Lutomirski , "Eric W. Biederman" , Tycho Andersen , linux-api@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] pidfd: change pidfd_send_signal() to respect PIDFD_THREAD Message-ID: <20240210124708.GB27557@redhat.com> References: <20240209130620.GA8039@redhat.com> <20240209130650.GA8048@redhat.com> <20240209-stangen-feuerzeug-17c8662854c9@brauner> <20240209154305.GC3282@redhat.com> <20240209-radeln-untrennbar-9d4ae05aa4cc@brauner> <20240209155644.GD3282@redhat.com> <20240210-abfinden-beimessen-2dbfea59b0da@brauner> <20240210123033.GA27557@redhat.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240210123033.GA27557@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 On 02/10, Oleg Nesterov wrote: > > On 02/10, Christian Brauner wrote: > > > > (1) kill(-1234) => kill process group with id 1234 > > (2) kill(0) => kill process group of @current > > > > which implementation wise is indicated by > > > > __kill_pgrp_info(..., pid ? find_vpid(-pid) ? task_pgrp(current)) > > > > We're obviously not going to implement (2) as that doesn't really make a > > sense for pidfd_send_signal(). > > Sure, > > > But (1) is also wrong for pidfd_send_signal(). If we'd ever implement > > (1) it should be via pidfd_open(1234, PIDFD_PROCESS_GROUP). > > Why do you think we need another flag for open() ? > > To me it looks fine if we allow to send the signal to pgrp if > flags & PIDFD_SIGNAL_PROCESS_GROUP. > > And pidfd_send_signal() can just do > > if (PIDFD_SIGNAL_THREAD_GROUP) > ret = __kill_pgrp_info(sig, kinfo, pid); > else > ret = kill_pid_info_type(...); > > (yes, yes, this needs tasklist, just a pseudo code to simpliy) > > Now lets recall about PIDFD_THREAD. > > If the target task is a group leader - there is no difference. > > If it is not a leader - then __kill_pgrp_info() will always return > -ESRCH, do_each_pid_task(PIDTYPE_PGID) won't find any task. To clarify, __kill_pgrp_info() should send the signal to pgrp identified by @pid, so it will return ESRCH if the target didn't do setpgid/etc. > And personally I think this is all we need. Yes. I don't think we should send a signal to task_pgrp(target). And this matches sys_kill(). I mean, pidfd = pidfd_open(1234); pidfd_send_signal(pidfd, PIDFD_PROCESS_GROUP); should act as kill(-1234). > ------------------------------------------------------------------------------ > But if you want to make PIDFD_SIGNAL_THREAD_GROUP work even if the > target task is not a leader, then yes, we need something like > > task_pgrp(pid_task(pid, PIDTYPE_PID)) > > like you did in the new kill_pgrp_info() helper in this patch. > > I won't argue, but do you think this makes a lot of sense? > > Oleg.