Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7262069imu; Mon, 3 Dec 2018 10:04:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/VWAFwphQfl2wNeKgSRBXo9tF1EDwqwpYzLoMwGsA9QMU9GRnHge7Rj34aWUQARyZH8CRx8 X-Received: by 2002:a17:902:2c83:: with SMTP id n3mr15931176plb.104.1543860246494; Mon, 03 Dec 2018 10:04:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543860246; cv=none; d=google.com; s=arc-20160816; b=mRTtheYiHa/JNFHIio3SGjV6FBppbkGJERrnsgEEVy0fvSxL2rp+fDjJ0IBF3NUg+Q YW+NAdMbzjaN4SmlbpNHaQJlCb8r9sKWL+EGrPWyk5lSFFALdXCTFRoDgA7cSkNB1ehC Kj5ac5N/1S3TmVIQvncXTHVfPnuETKFa50t6PXukyWYALZVJWG2aT29/RR89CAPQbFvA F9CWwkKh1XeurG7CXuc6pnlS7Y8qSAUdvnN1uTay8UHIYA1yFswIL3/6NG0TjBn5X85L fzVaTJ6VAKzyBBbUUY198DK2kfzHX5eoor8gKollJH4rVDfIlQ+wt0Jjx54dt0IQBi6w KBfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=eqqP54wabPUX+OmiVWkeTn8AzREjJ55DW8J3hKtKwhI=; b=wFBZk/k7EM9eGhqdOkYo7yOa2/12e3U60bH11eS0JPRV+qqWvGb804m50KnvpvbXeH GIyK4J/Ifs/3l+zDA/8jWAe1gV0iMpKq1enxinSSOd5JNl8ic0thcFEpXIrylNmeeY8R nbZUmrO+SaeVdx3lX5hxhTiJZChpCboc2UjAtHjQ0su2uZ6yGc84bQrtt9BWLSgFSjRO xItGUB8tAA/bPjstEb8Az5Tpv1volCxyLNW44M16bvRhHhPrsQ2t50ovzedD+eK2KJa4 Iu7SP6qSNgcSy49B6yEcLzMHn/BxpoMPaGl895H/mxIBCd9rC0Fd3z+qBRY6NeKGHHZ0 1o/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=W5h32lTw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j10si14004054pll.179.2018.12.03.10.03.34; Mon, 03 Dec 2018 10:04:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=W5h32lTw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726833AbeLCSCq (ORCPT + 99 others); Mon, 3 Dec 2018 13:02:46 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44283 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726394AbeLCSCq (ORCPT ); Mon, 3 Dec 2018 13:02:46 -0500 Received: by mail-pg1-f195.google.com with SMTP id t13so6044152pgr.11 for ; Mon, 03 Dec 2018 10:02:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brauner.io; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=eqqP54wabPUX+OmiVWkeTn8AzREjJ55DW8J3hKtKwhI=; b=W5h32lTwRYgQIQ1ZOyQYXyOHs8RoAWB0LKhQ3AbL0a87TwgjlJuHD+o5gSfRqyqMUB jpDP0X+MiX2Kt16A5jsesYZBdX8IwgDFFLYsTcGZhPUMsgQvaH4zzLWdW+OC3JdLNfdm ovrgEN2JuFnZFpzu68a/V13FrPg65u2fm53TImoI4colerThlYGZ6wdo+a35v2Ho7RIr ChiydNymMsg9IZpgbrJMlFvxPNZzvq4bl7aCAizr66lauNJWEBHxYIjEbPQYn28xX559 aOYQlVnshR6KPFZC0HBdpp8E6fGe1U1rdXj1Irrj60gr9lyaBDe2CECSGZ1UdOPmzv7l YTyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=eqqP54wabPUX+OmiVWkeTn8AzREjJ55DW8J3hKtKwhI=; b=bggYu5nHHcHKjN/btiDAa16qLJUgAajteQI1Kzn82A6CFJ9qJx1prL7sqK0ch8CVb8 JhCPdWr/oIT8qnEH61tFzHTIDDxyikEwRr77USzFI/mUjfS3lXvJDTADSGeqVpiNIKGy Sl5ohII2HKyC4LRSbnx3oM8homeXWPMU9B0ET/Z6YINN51Ac7LNyPg0QgYaz9AXx6GZG Fs92XH2ApuJcPr0u8xKtLgITfksf92J3/krOe++A9zutIWP4BRgGX20dnt/KSEMcUr5g P84Ic25to8GZjdT2P1mmfkpOT6Jwt95g0up8uuJfpH9AiZK0Uv2+qvkS1EBimrPFH/9I VZyA== X-Gm-Message-State: AA+aEWYHaXt1YtRLrhNkS7zOih3wqQMDEbLH717VjMk9IDqsMjlHM4gB TER0wXZOD4zhhQsr9DVru1XQuw== X-Received: by 2002:a63:8742:: with SMTP id i63mr13871700pge.298.1543860159208; Mon, 03 Dec 2018 10:02:39 -0800 (PST) Received: from brauner.io ([2404:4404:133a:4500:b824:a031:b50e:f401]) by smtp.gmail.com with ESMTPSA id 4sm23625479pfq.10.2018.12.03.10.02.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Dec 2018 10:02:38 -0800 (PST) Date: Mon, 3 Dec 2018 19:02:29 +0100 From: Christian Brauner To: Florian Weimer Cc: ebiederm@xmission.com, linux-kernel@vger.kernel.org, serge@hallyn.com, jannh@google.com, luto@kernel.org, akpm@linux-foundation.org, oleg@redhat.com, cyphar@cyphar.com, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, dancol@google.com, timmurray@google.com, linux-man@vger.kernel.org, Kees Cook Subject: Re: [PATCH v2] signal: add procfd_signal() syscall Message-ID: <20181203180224.fkvw4kajtbvru2ku@brauner.io> References: <20181120105124.14733-1-christian@brauner.io> <87in0g5aqo.fsf@oldenburg.str.redhat.com> <746B7C49-CC7B-4040-A7EF-82491796D360@brauner.io> <20181202100304.labt63mzrlr5utdl@brauner.io> <8736rebl9s.fsf@oldenburg.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8736rebl9s.fsf@oldenburg.str.redhat.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 03, 2018 at 05:57:51PM +0100, Florian Weimer wrote: > * Christian Brauner: > > > Ok, I finally have access to source code again. Scratch what I said above! > > I looked at the code and tested it. If the process has exited but not > > yet waited upon aka is a zombie procfd_send_signal() will return 0. This > > is identical to kill(2) behavior. It should've been sort-of obvious > > since when a process is in zombie state /proc/ will still be around > > which means that struct pid must still be around. > > Should we make this state more accessible, by providing a different > error code? No, I don't think we want that. Imho, It's not really helpful. Signals are still delivered to zombies. If zombie state were to always mean that no-one is going to wait on this thread anymore then it would make sense to me. But given that zombie can also mean that someone put a sleep(1000) right before their wait() call in the parent it seems odd to report back that it is a zombie. > > Will the system call ever return ESRCH, given that you have a handle for > the process? Yes, whenever you signal a process that has already been waited upon: - get procfd handle referring to - exits and is waited upon - procfd_send_signal(procfd, ...) returns -1 with errno == ESRCH > > >> >Looking at the rt_tgsigqueueinfo interface, is there a way to implement > >> >the “tg” part with the current procfd_signal interface? Would you use > >> >openat to retrieve the Tgid: line from "status"? > > > > Yes, the tg part can be implemented. > > I meant on top of the existing interface. See below. > > > As I pointed out in another mail my I is to make this work by using > > file descriptors for /proc//task/. I don't want this in the > > initial patchset though. I prefer to slowly add those features once > > we have gotten the basic functionality in. > > Do you want to land all this in one kernel release? I wonder how > applications are supposed to discover kernel support if functionality is > split across several kernel releases. If you get EINVAL or EBADF, it > may not be obvious what is going on. Sigh, I get that but I really don't want to have to land this in one big chunk. I want this syscall to go in in a as soon as we can to fulfill the most basic need: having a way that guarantees us that we signal the process that we intended to signal. The thread case is easy to implement on top of it. But I suspect we will quibble about the exact semantics for a long time. Even now we have been on multiple - justified - detrous. That's all pefectly fine and expected. But if we have the basic functionality in we have time to do all of that. We might even land it in the same kernel release still. I really don't want to come of as tea-party-kernel-conservative here but I have time-and-time again seen that making something fancy and cover ever interesting feature in one patchset takes a very very long time. If you care about userspace being able to detect that case I can return EOPNOTSUPP when a tid descriptor is passed. > > What happens if you use the new interface with an O_PATH descriptor? You get EINVAL. When an O_PATH file descriptor is created the kernel will set file->f_op = &empty_fops at which point the check I added if (!proc_is_tgid_procfd(f.file)) goto err; will fail. Imho this is correct behavior since technically signaling a struct pid is the equivalent of writing to a file and hence doesn't purely operate on the file descriptor level. Christian