Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp305456rdb; Thu, 8 Feb 2024 06:35:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUjxCTtRjlLdakz188nFtqd2BKa4e1CrFzUB3DwBmoOWrPJt/brcHazq+uCpmevIjH/pkG8oDj4zXNHt/M5USzRKQbqGpdsd3fz8KE5Mg== X-Google-Smtp-Source: AGHT+IGJZ6CzWnf5BaQJWrhqKlDNiyG/GffmYoNxHCjDuzGnmmkcXM6tuaupnKsJzZ+UVHKCqMID X-Received: by 2002:a05:6402:350e:b0:560:c951:57c5 with SMTP id b14-20020a056402350e00b00560c95157c5mr5259743edd.35.1707402940804; Thu, 08 Feb 2024 06:35:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707402940; cv=pass; d=google.com; s=arc-20160816; b=k/AwJkMcG+ExqnTqV8huruJifa2ASkrJeDNyaql+okZLO4FHyis6VslX6ffFEX/0tC lpimLpL6K0HcI1I71jYuAvgPrVkdiBtCHLGXGm0QSNPYNKUPRUVlk32OMUnXEkklKcjX TgPdtztiHC+W/l2ay/MU++d0xvWAJJ6X7O3LbktGQxM4ZJNPhtWLzQpuLqxURMxrkzmh L6iuz4oeJ+j0iwZQeLFLRiPktxGZNPGTvg6V4d+/0LVlBGX04N+HYiWmnfYKsnW319FL 0SG7DNqwSkLN95WDjfhYLj+Aoog4xALKt7IwfI9xPK5dn7YejQQq7RJsXrRQWg05B+VC oMrQ== 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=rIFybJDnOhyzqhit+HnnDJoYVstx80eqvFnajir605c=; fh=XRHVRrQklkLtkutTHuglmdiqhAFYVl+onrsjlpRfCZM=; b=ZFSr3q2QLmaskP13g+QdtdDlAiPh6/0H8mrPJJnD0SHbcDYnJ+eviLHBrDhEDAGrAy nqO/bP1p1C/EVbT60bxJQIwWK84EWB/LveFn7/XOZewmFCr0O9pfO30ym7EnuRaQYxLy xn1m/VLqcYuTPll1hWUHec50e3aIkCzfXn+D3wSwZtJJW2GtKT1uHTSM/v18XJdDNdZP 0R7B12C8LiTX1lRVVLFVEKqW/ZG9b017jqRpI8pHZrLsOOmeKvUoTL9RUl9ltBEcSfq8 9RhTpbx+2x0a9w/FH3g3Hr2PUHU1EJh/xq8aXIz4Oo9V5s0FMWOJiHNhZli7uHMvLOwm MqPw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=L6szAznS; 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-58239-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58239-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; AJvYcCVbY7M66mNRAUzULcgpeJFfqwke0CQ68pEwUh73a0e3yIglKuRdTj1tIhsWUOgvxEjyyDSVTgBCm4uTla7ph7ck2pg3jPmHvn1uhl61Lw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id dh27-20020a0564021d3b00b00560efa502f1si980508edb.554.2024.02.08.06.35.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 06:35:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58239-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=L6szAznS; 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-58239-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58239-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 8910D1F243C6 for ; Thu, 8 Feb 2024 14:35:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB4FE78B75; Thu, 8 Feb 2024 14:35:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="L6szAznS" 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 266506EB4B for ; Thu, 8 Feb 2024 14:35:29 +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=1707402932; cv=none; b=ka8jrvYiHsAJHFCdZwxg0KX3hPRIXtdpVZ6co2z2ormVagpICkaFjgSalMDo8BXP/ohrzg5QOE0U4DY3y3RqyvUlI7qqD0EhqX6yob7D3Nm5i52wsEquUu5KeJP86P1IYsYRpjt3DAZZgWHEj2qlObl2Ifyf0kSGYYXKB/Iuna4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707402932; c=relaxed/simple; bh=9YqzliOGzkkMDhfypshk6U0P1+CqguZTr81ooRTLRZU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iuYqhar1vsL7zvoQkeFPpEXLHsxIs1+3zuZxYIcoYrqO8WaO0xFfY/RETr3SH1BYLwOyrv/45qjHS0iUED/JBZgr6TZ1IcBs+42EGD23D0/cApYZPKTJBv+3eNFhZSobSRBMfvVOSIdXtaF0GadALnfQjM/5L/W1l+BajUtxfe4= 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=L6szAznS; 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=1707402928; 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=rIFybJDnOhyzqhit+HnnDJoYVstx80eqvFnajir605c=; b=L6szAznS7mh/uZM80v2NhZN3JjI+hq37P+TGlGrtjDQrZI6/p5TrLnEbclXNw3aKdM4wfp LaHHQL4pgdp4DZ/fNVQs0zmo4C9/FR7GI8YXs8UzSzKF7VwtvjdwEFiQqyQpvpbKR631tI OEOa9CwPIIbZ3ifHFfXfSWul3UCxepc= 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-691-mHzfyN9iPPuu-h2TqO4tDA-1; Thu, 08 Feb 2024 09:35:26 -0500 X-MC-Unique: mHzfyN9iPPuu-h2TqO4tDA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 A8DFF84AE41; Thu, 8 Feb 2024 14:35:25 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.224.158]) by smtp.corp.redhat.com (Postfix) with SMTP id 0B0BE492BC6; Thu, 8 Feb 2024 14:35:23 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Thu, 8 Feb 2024 15:34:10 +0100 (CET) Date: Thu, 8 Feb 2024 15:34:07 +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] pidfd: change pidfd_send_signal() to respect PIDFD_THREAD Message-ID: <20240208143407.GF19801@redhat.com> References: <20240207114549.GA12697@redhat.com> <20240208-fragt-prospekt-7866333b15f0@brauner> <20240208135344.GD19801@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: <20240208135344.GD19801@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 On 02/08, Oleg Nesterov wrote: > > On 02/08, Christian Brauner wrote: > > > > On Wed, Feb 07, 2024 at 12:45:49PM +0100, Oleg Nesterov wrote: > > > + type = (f.file->f_flags & PIDFD_THREAD) ? PIDTYPE_PID : PIDTYPE_TGID; > > > + ret = kill_pid_info_type(sig, &kinfo, pid, type); > > > > If the user doesn't provide siginfo then the kernel fills in the info in > > prepare_kill_siginfo() a few lines above. That sets info->si_code to > > SI_USER even for the PIDFD_THREAD case. Whenever the info is filled in > > by the kernel it's not exactly userspace impersonating anything plus we > > know that what we're sending to is a pidfd by the type of the pidfd. So > > it feels like we should fill in SI_TKILL here as well? > > Hmm. Agreed, will do, thanks. Cough... lets forget this patch for the moment. Is prepare_kill_siginfo() correct when we send a signal to the child pid namespace? si_pid = task_tgid_vnr(current) doesn't look right in this case but perhaps I am totally confused. And why do we need it at all? Can't sys_kill() and pidfd_send_signal() just use SEND_SIG_NOINFO? OK, I am sure I missed something. Will read this code tomorrow. Oleg.