Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2207874rdb; Tue, 20 Feb 2024 23:42:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUF2At44Ic9+ETDe5Yf7KVUL8DGclMyTPT6n2nm3SgBoepLmo7UVqU9EZLLaMa+UUs9yR0kDEtX1XkQbgVBAzOmuqqdXlO/wC3VEG551A== X-Google-Smtp-Source: AGHT+IFJ4K1T3wl6++g7vQ3cBYnog2aib7LcFvBQm6fCJnODrT07/u0yNqPCtYsp24LrMmi7U8ln X-Received: by 2002:a25:29c2:0:b0:dcd:aee6:fa9 with SMTP id p185-20020a2529c2000000b00dcdaee60fa9mr17316739ybp.53.1708501374637; Tue, 20 Feb 2024 23:42:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708501374; cv=pass; d=google.com; s=arc-20160816; b=K/xdDY1SluxnFeMa4/Jt2JdzeP4H07QQZDjdLwWW7Sa6c7GnrSZnREIIAtv9SKYSqc yjTxFr9msRbGERpZuLRcySx4lCldMsor9Nzco+TpmMwsnTerqpZ32jwjQmcwu0TQEKEa Uu9sAVUpWjnpw4+twNOFkSs7tpNuDINAozhYuqrVWzeh9N6y6qV0vHhiKmbkKvY6Xu8H D/AzTve4faXCxZsOoJ3oUji+h2E6o+dHfer9+qrxZ6PdJGBjjIK+QqjLMf37DlVZLuty +jvNTbwnjhi6kHwlZqrzuoC5eI8mJzUNuRU3mBqToNSxjTDBmv8cU8zoSmGjH+W+NF3p K50g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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=8WVoxgz1JUCbr2fKqkmOB4Oaw8AoeM6KI+aqdswDTso=; fh=c5+wgcC53e/Tri1Y6qjwKhun+2zDBL/8f9SJuYaUy7E=; b=MvioKd26N0ezyl3IJRw1M4xNEdGRUJ0T9EziYmu72ViA7wlYDlbpRchKMtmT2VWCaR anF0SlyRzqetH4Tf04qyELQgoHxK1nPRmRhnKn1AlGPEjNvnZQr408ap8rWdnc4aBCmN 242k0NsWP/SsL+AtN6ItuSrOxgz98gs4cjYc9nj4r/GF9M/e/j5P1PiFH/iRbz9jjFVI pKmnA2oYWLNfH2gc/uobMN5hijuNUrle01pWl9vyEoVy2DAK7BXCEV6BUgMEuBsphTcU p771obClIgq26YA3EKkO/JTfrKDMRuCQpqx3WMwhVHZV5cR9bA178QdsWyIKo54lZA5D g5aw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bpNqZ7zi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-74251-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74251-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l22-20020a637016000000b005d8e379746asi7540174pgc.630.2024.02.20.23.42.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 23:42:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74251-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bpNqZ7zi; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-74251-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74251-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 98E34B2327F for ; Wed, 21 Feb 2024 07:42:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D06873AC34; Wed, 21 Feb 2024 07:42:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bpNqZ7zi" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E43553A8FF; Wed, 21 Feb 2024 07:42:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708501364; cv=none; b=u06Ex1giY2QDU/0Mk2QI89DMdcDKbLMBTGK1cXCOEk10UGIypzBGov1daaWMRXfQsnMb29hRjJaBXUWVQoGk6pYHOEt9JSzclun/mGdkGgk9QlYJzn0aLinGcieg4hQ9PtGOtpo7fYlY7R2gmuWMkx8XE8v4LOzjhVKFNtdxjyk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708501364; c=relaxed/simple; bh=uXAz7xXdcMNahPSHz+7qP/fjoRiyBQeWYpw6GfEaaLc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=s+o8GCi8PLKbBEBYbcs7qysV4+pNkE6eMpTrgoVXR1EBPzPinXSaG3a783kdsv83ZbC5Ge6+6k+FWRVaKMb/WjbXdx8Llqy3kqioQy230wU7dKA6wvXcJHJc5c8ny+Q21osFmVZAQpy0jIUgAWXy53+YYnhMPw+O4XNZzu2RmCo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bpNqZ7zi; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0691C433C7; Wed, 21 Feb 2024 07:42:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708501363; bh=uXAz7xXdcMNahPSHz+7qP/fjoRiyBQeWYpw6GfEaaLc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bpNqZ7ziO14grUIYwy2MhFcYCRf2S/zmY0GlzrtHJIbBsYjeGHTmMMcfVaXJfFWRk y1LHfAfoFnJE5GKdlRe1ST9BLbfLq2Eu0tH0RPBKBTVUUwPdrUOjc6rRcitVkEoZXO 7e1RoD1mBgafz0qfT4SBTeysmdoSFywhRB9pyIwcyo/DLpxsTruohTJUwD/hyYL+w7 z5QgzRn/oqoTsbXq3G3VzHoZzv/gTu1loZ7rvBDiSY6woJOfzTmZ8Ph1/uIsDI9IBG XalnrB3PfinJQ7uZGUS2ocoQlJv3EFK5tmkNm6g3HiVKZAofC5hufbE2cJdkNz5jhK F9hC/IctSCApw== Date: Wed, 21 Feb 2024 08:42:39 +0100 From: Christian Brauner To: Oleg Nesterov 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: <20240221-zapfhahn-pulsschlag-e8f9d919c350@brauner> References: <20240216-albern-aufwiegen-1de327c7dafd@brauner> <20240216130625.GA8723@redhat.com> <20240216-ohnedies-improvisieren-58edcc102b6a@brauner> <20240216181214.GA10393@redhat.com> <20240220-einwurf-depesche-d8682be0370c@brauner> <20240220090255.GA7783@redhat.com> <20240220-pragmatisch-parzelle-8a1d10a94fae@brauner> <20240220110012.GB7783@redhat.com> <20240220-anlegen-feinmechaniker-3c2cfcc3ec01@brauner> <20240220162201.GD7783@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=utf-8 Content-Disposition: inline In-Reply-To: <20240220162201.GD7783@redhat.com> On Tue, Feb 20, 2024 at 05:22:02PM +0100, Oleg Nesterov wrote: > On 02/20, Christian Brauner wrote: > > > > On Tue, Feb 20, 2024 at 12:00:12PM +0100, Oleg Nesterov wrote: > > > > > > Perhaps we can kill the "task_pid(current) != pid" check and just return > > > EPERM if "kinfo.si_code >= 0 || kinfo.si_code == SI_TKILL", I don't think > > > anobody needs pidfd_send_send_signal() to signal yourself. See below. > > > > Yeah. > > You have my ack in advance > > > > > + /* Currently unused. */ > > > > + if (info) > > > > + return -EINVAL; > > > > > > Well, to me this looks like the unnecessary restriction... And why? > > > > Because right now we aren't sure that it's used > > Yes, but... > > > and we aren't sure what use-cases are there. > > the same use-cases as for rt_sigqueueinfo() ? Specifically for pidfd_send_signal() I mean. To me it seems very unlikely that anyone would be opening a pidfd to itself and then use pidfd_send_signal() when they could entirely avoid this - race free - by simply using *sigqueueinfo(). But I may be wrong of course. > > Christian, I won't really argue but I still disagree. > > Let me first repeat once again, I do not know what people do with pidfd > and pidfd_send_signal() in particular, so I won't be surprised if this > change won't cause any regression report. Fwiw, that's fine as long as we'd fix it up. > > But at the same time, I can easily imagine the following scenario: a > userspace programmer tries to use pidfd_send_signal(info != NULL), gets > -EINVAL, decides it can't/shouldn't work, and switches to sigqueueinfo() > without any report to lkml. > > > Yes, absolutely. That was always the plan. See appended patch I put on top. > > I put you as author since you did spot this. Let me know if you don't > > want that. > > Ah. Thanks Christian. I am fine either way, whatever is more convenient > for you. > > But just in case, I won't mind at all if you simply fold this minor fix > into your PIDFD_SEND_PROCESS_GROUP patch, I certainly don't care about > the "From" tag ;) > > A really, really minor/cosmetic nit below, feel free to ignore: > > > - if ((task_pid(current) != pid) && > > + if (((task_pid(current) != pid) || type > PIDTYPE_TGID) && > > we can remove the unnecessary parens around "task_pid(current) != pid" > or add the extra parens aroung "type > PIDTYPE_TGID". > > I mean, the 1st operand of "&&" is > > (task_pid(current) != pid) || type > PIDTYPE_TGID > > and this looks a bit inconsistent to me. Ok, will do.