Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1489569rdb; Sat, 10 Feb 2024 04:32:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW8kbidVNQpORVrM5lv3G6zlAvkBVb3w+WERXSfXQsLpLjk4jo/i05PEHSMSNEFuQ0rmRtuS7EMLIp0xLvWlftp89bDk2M11DBNjxyd3A== X-Google-Smtp-Source: AGHT+IF0L8btl+IjuQMQLvSRYe+BVBmgHQnKmqq5p4MBhPlYdyIYsIbPbQ0ty1dbY5bVf/NUJe3R X-Received: by 2002:a17:906:f1d1:b0:a37:2ed2:cba1 with SMTP id gx17-20020a170906f1d100b00a372ed2cba1mr1333158ejb.22.1707568327810; Sat, 10 Feb 2024 04:32:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707568327; cv=pass; d=google.com; s=arc-20160816; b=uvBdrELOcLaa3M7S8uhEmTZ2/V+rCge13tcLn42pn1CClX2bLHzDjfDbLo2J0Wp8EM i3mjX6VjxA6mPZxuKS4Jgvjn2cKDx/4hKG6faVH9NSuCYiEpr4NK06J3Ds2RRNoYmfFs JUIXIfIM6ivey/bZMVshQwtBMuxB5Li9mkP5KS6m8vDZiqiX1/3m2rotEIixjwjbddWJ CRuy/dvX/KTPXSZNnVtQpDndMHzosIZYT2kgDHBDzlTojfwOBEBtGddouLRwAPxEPN1f +kt6Sid5pEUzZVCXdSC5wM8xWuUetXEPFHwKty6arxRi8KJrlDqbRFf2b/D9Z5OChzXX i7Ug== 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=rsa8Sa2RaRjXmbcIJ9/cp3lURU1N9XcuIpnY+VN8kcI=; fh=1bnSdcVT3M7YjPv5xBFcQjvvYqj8KCEYILCQqXKZpJc=; b=ahYog0vcFe1KbN1UA2HXz93bMAt13A2WispmsKlh3DH3RqEsxp8aMA5CHL3ouIgEtc DDLABOox6gFXpndVa0RU/ru0A/TtVtIt+rTcuqDRrvUAhy654zEOLwDffSbFjb/48XJR F7q2DlH0k+xmDzPzQPtmshFH/Pu/xap83Fv5uNYHM0O2ocijLBxm4eipHKAy8SsgYZPI +9YGNsO4T9dfvta9/ma8Okube6xbDtWI9Xg65yZym6O6KTHfPHczhoo5jUkXoE53PS8+ 3d2fp4ZUuLWjGLYZdxdp8GJv0DuxmYz9pAbct7E95IeMBqiaDF6yarCBetgPD0sVtylA Rbbw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AXReNp7G; 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-60396-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60396-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; AJvYcCUJPdLs3CUfC7aBL76K0rC0VmXpxMXSw8inw/jxxgeYuJGvlizayhDXno1PDuQlgqae1p7lCei827hLt5Z84XwUZq/fpAQ1wSggJKsXRw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qx25-20020a170906fcd900b00a38a476d381si1926634ejb.41.2024.02.10.04.32.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 04:32:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60396-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=@redhat.com header.s=mimecast20190719 header.b=AXReNp7G; 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-60396-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60396-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 8E2D41F21D9B for ; Sat, 10 Feb 2024 12:32:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7BA4B47F5A; Sat, 10 Feb 2024 12:31:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AXReNp7G" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 26C223EA66 for ; Sat, 10 Feb 2024 12:31:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707568318; cv=none; b=Hy0fv2sf7xej1OUtx+Hq9hawQ7s+3hfraFOHAYDk8Qj3DhAJOdTvjP/ipqluGb03n+7NYGEgP3lHK4uv4bx8O06pe1rS7rCargLJfxtcq2b4krJyT2tl+QUQT/mktp5Q/BTSfxobwEMBQ+rh6YOrobFZXLXI/FZQu3YT7f5i6Og= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707568318; c=relaxed/simple; bh=b/+bunSHR5UhPdFTXfBKcRLs2qkDpn8Qrz7Q+Zf0Neg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RvfuV+3c0fL1222liOWND8UpxQkirLC6Bup8A4+ltOA7VrkahbvhChiL4RInwr/fCRRDWWYCqHf3z4PKWUg9pBXICsQ999OhoiSuHjjp/GNweooNFcQS2J0Br/YgxXfGVY97HpR7VLLIS7pe3xSh3cH4xndbeaPY1uHCbR5KdwI= 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=AXReNp7G; arc=none smtp.client-ip=170.10.133.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=1707568316; 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=rsa8Sa2RaRjXmbcIJ9/cp3lURU1N9XcuIpnY+VN8kcI=; b=AXReNp7GN5C3BWNiOzedgxO5AcPjqEQzg5JXDGWoRX71UiqUNqCSA4NItOwGvlS2Eivn+5 m083+AV/XjCFvjioZ3FvR4QAXB/KPX2is3eFv1Xff+YSzOO+6H2ipqEUfKRsmgH2u4USSE sEYLEVmsFHEpRS+9F0Z4WPElOTLNr1s= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-562-euPsEMJsOUOA3OZtIC3yHg-1; Sat, 10 Feb 2024 07:31:52 -0500 X-MC-Unique: euPsEMJsOUOA3OZtIC3yHg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 9B560380451B; Sat, 10 Feb 2024 12:31:51 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.224.28]) by smtp.corp.redhat.com (Postfix) with SMTP id 13E2840C9444; Sat, 10 Feb 2024 12:31:49 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Sat, 10 Feb 2024 13:30:35 +0100 (CET) Date: Sat, 10 Feb 2024 13:30:33 +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: <20240210123033.GA27557@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> 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: <20240210-abfinden-beimessen-2dbfea59b0da@brauner> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 Christian, Thanks again! the last 2 commits in vfs.pidfd look good to me. As for this patch, I am not sure I understand your concerns, and I have another concern, please see below. For the moment, please forget about PIDFD_THREAD. 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. And personally I think this is all we need. ------------------------------------------------------------------------------ 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.