Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4352824imu; Mon, 24 Dec 2018 23:14:11 -0800 (PST) X-Google-Smtp-Source: AFSGD/VdOaehZLTj+ASTo/gDCPvRfvu6ZkbljcKjPV1ujTrI5iCwnE0UqD9OocRdpJShUTcUIYRL X-Received: by 2002:a62:5182:: with SMTP id f124mr15865360pfb.238.1545722051405; Mon, 24 Dec 2018 23:14:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545722051; cv=none; d=google.com; s=arc-20160816; b=gvhWGvzVzUtMmnpuIAZ81s+a1XYPoSChnvYTpjKqGXMUjzb9Coka2isB2hgqZ3FfJ3 qgT+CBMW55aQ/Tp+OFlpKdXgFoNOTqSFFbffBzTmjpP7DNBw1JNZrNsAlH67WeUeU0BQ abhd7cKip77WF3NhAbpOqXri5ChuidYU4jN6r0WC0oZUYeo57shyCjXw00AluGlvifxB 8nnANVKwCzphDdBnF4LX/ZH6FyTz8dEj2kySRsrJeMgNs4M1ehKEBp605500pLTn4b7I n/GW56rospWneGZ0fDdz/fDgk9Y9afzZ6D8a0a2XlXXadeHoYvAP304fForBul1+DIw7 AOXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=29HFdbwKJBK4EvPrtEg9nBilc/E/bzi4iPIpXsw/yhk=; b=VYEbB1yzOwb5fM9HdATn5TnKRtiYDmhBbo/y/ngf7G2TLd3HDmwT3ixIlmgYbXOFSh sGbRZS1fC8Ym/oNS6dBH5tO9Zuj8ZxHW/Db35/j76D4ny17Lch60RBfnzLateozi1+O0 NLLy5FYlyeDzzJzvyK+7cShNd5M+d76HVDsgaGr61xLmwWhWkxVq83ueoyoxD+E5Wy3C YDTRIEBHxIwtXsD2/P+dXRZ9DjsNUfualwYQukEx025joIzgiF7gjf2ODNa7TPBFz4Mt f4eMQ+c5ceZJYp7yI9Lk+r79tU7peL5/M0LG3S6hcFcUCK3+ZBpKbNMXCDFxsXUwCMME 0yGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hdj629Vb; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z10si31195032pfm.37.2018.12.24.23.13.29; Mon, 24 Dec 2018 23:14:11 -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=@gmail.com header.s=20161025 header.b=hdj629Vb; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725884AbeLYHLS (ORCPT + 99 others); Tue, 25 Dec 2018 02:11:18 -0500 Received: from mail-it1-f194.google.com ([209.85.166.194]:53473 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725827AbeLYHLS (ORCPT ); Tue, 25 Dec 2018 02:11:18 -0500 Received: by mail-it1-f194.google.com with SMTP id g85so17774480ita.3; Mon, 24 Dec 2018 23:11:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=29HFdbwKJBK4EvPrtEg9nBilc/E/bzi4iPIpXsw/yhk=; b=hdj629VblY39X9PuGUXyc63kcRJN/Oh8V9QzVlgvqH87urtQufWB4+CjlWk2nkT+1i m2SDb/hs+yu5jJFxXj/OCHtkiRUN4EkzHE2bC93v+19eYvwcfNw81AO8UmXW3psd/y76 gX326J/yTcoZUw+1SiSeETJ4a22+64UsqWHULpiAJ58MjYTwe/jamA1ICjQ6PAStBcU5 W4QY2iJ3VJKth8LerIfjUnrvV/DAskL9kT4+wK+4/HbLK95p2TKflVRKR0wkRKXXEiRK acjJgU5oG2NIEE79tg0vZWASr1IlXM9rVi7kLgKQaU9sfre6fCkOCIcnvWKZm7f46PWw ZnzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=29HFdbwKJBK4EvPrtEg9nBilc/E/bzi4iPIpXsw/yhk=; b=eiUR0CRUqSYdZeFGlUowV8SLQUXNS9u/IHWUUmsJ8KkjR68Ee09DLgq1gl4RMUKuJ/ 6iwMUb3jexVZ25Ys+FDArx6lJPK0loWu7TLSaaU1tFbtnzzqtxY9jE7giRB2lYJEG+NS FmlVR/YNTq/zpgOkWp8FBi5k00ERoOQp/Ns3Fl/DrIBu4syXm1LO0wRK7QgrFVCTS+6y 3+mfXeq1CNWDbZFXMrOzpfF/de5bY180dQ2Kv2Mx9xSyAwd+vYL3jYnO0O3pEOuQctix JG66Y34MFmjFJUqT4RYArapvfz+Ajno3Jdeuw8G6U4YLC4kgMDh+x3Q123KvKGxrqSqP Wj6w== X-Gm-Message-State: AA+aEWYRbbt9mKK5qep5PEubh5doDpG0dyyqNovx61gZLLODiiSyvzD3 aGQiZixi2g1Cm/wKlew9RiXO4KUwGTMLmTWg+Qc= X-Received: by 2002:a02:6915:: with SMTP id e21mr10421243jac.142.1545721876652; Mon, 24 Dec 2018 23:11:16 -0800 (PST) MIME-Version: 1.0 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> <20181203180224.fkvw4kajtbvru2ku@brauner.io> <874lbtjvtd.fsf@oldenburg2.str.redhat.com> <87y392h4b7.fsf@oldenburg2.str.redhat.com> In-Reply-To: From: Lai Jiangshan Date: Tue, 25 Dec 2018 15:11:05 +0800 Message-ID: Subject: Re: [PATCH v2] signal: add procfd_signal() syscall To: Christian Brauner Cc: Florian Weimer , Andy Lutomirski , "Eric W. Biederman" , LKML , "Serge E. Hallyn" , Jann Horn , Andrew Morton , Oleg Nesterov , Aleksa Sarai , Al Viro , Linux FS Devel , Linux API , Daniel Colascione , Tim Murray , linux-man , Kees Cook Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 25, 2018 at 1:32 PM Lai Jiangshan wrote: > > Is it possible to avoid adding any syscall? > > Since holding /proc/pid/reg_file can also hold the pid. > With this guarantee, /proc/pid/uuid (universally unique identifier ) can be > introduced to identify tasks, the kernel generates > a uuid for every task when created. > > save_pid_uuid_pair_for_later_kill(int pid) { > /* save via /proc/$pid/uuid */ > /* don't need to keep any fd after save */ > } > > safe_kill(pid, uuid, sig) { > fd = open(/proc/$pid/uuid); /* also hold the pid until close() if > open() successes */ > if (open successes and read uuid from fd and if it equals to uuid) > kill(pid, sig) > close(fd) > } > > All things needed to be done is to implement /proc/pid/uuid. And if pid can't > be recycled within 1 ticket, or the user can ensure it. The user can use > starttime(in /proc/pid/stat) instead. > > save_pid_starttime_pair_for_later_kill(int pid) { > /* save via /proc/$pid/stat */ > /* don't need to keep any fd after save or keep it for 1 ticket at most */ > } > > safe_kill(pid, starttime, sig) { > fd = open(/proc/$pid/stat); /* also hold the pid until close() if > open() successes */ > if (open successes and read starttime from fd and if it equals to starttime) > kill(pid, sig) > close(fd) > } > > In this case, zero LOC is added in the kernel. All of it depends on > the guarantee that holding /proc/pid/reg_file also holds the pid, > one of which I haven't checked carefully either. > Oh, Sorry, I was wrong, the pid isn't reserved even when the fd is kept in the user space. And I'm sorry that I had replied to an "old" email thread.