Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2910623imu; Mon, 19 Nov 2018 07:58:37 -0800 (PST) X-Google-Smtp-Source: AJdET5eiHKx/mJRf9Ebx3ORm7VoQeLQa19UX5yA/+8oQoIbD9gHkPu+H6dXGaTppwFYrmPDTvgoD X-Received: by 2002:a17:902:8d83:: with SMTP id v3-v6mr22923979plo.162.1542643117592; Mon, 19 Nov 2018 07:58:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542643117; cv=none; d=google.com; s=arc-20160816; b=IGsNZ3JWW+4H2KHMRdTBaz/NvzYFr6qjZiHgYn7W4d3cHjvtPeLMFUE9PBblxyVJmD tpe3wCQqKAXBjmABF1jQQAb+5b/Tbt9hmJ+NNNNkhy4vW9uxgdVCg0/E5qVrF6O9gFwY 3WIcKtX07dw3RFXRvf32LwJfEm7mmuCpt89I94+Ge6+hIjzD9nYWJLdo3WXvwakihZvB UyLh8U4M/fTM0kmd9B3HOVhrogLZRwFlj7OT1REjU+Z4FkTUVorssvq7z/cfjyLJRRsP eanquSbP+2x3vbm6JMPkTHglCQungcWIIctAtrCt2fflHYBHUhgAc3EcghIk+Er66FcG dR3w== 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 :references:in-reply-to:mime-version:dkim-signature; bh=9nI9EDei5NGcqe3JqwT0iOoVckuBXoqey9NpE1OlEpQ=; b=KNd6AqPIjg96m/YVRQVgrYCmXC9QAXoLwAUsXG47wYnN+2CzLYrkKfvoYPmvcpgqwP 77JD4IQpazDQvC3NiTXtD80ZixsamO5QDWNeA/DuAoFL8RGy7+bZe8wakzkBNHeN+8V5 CJmw06yPyMqEbRnUQ4Cl59PKYeK8PJorQ0/SGxOFlkJe7U0KNJDxvTGdTNPEkUL8lM5c B/gTy2wF7oRt5U/f/u1n/Y4HCRxenHPCyhsz/tLwEr/OLfx/87yn+K1DqEiWR1+NYg6o HB0guJ85wC9VSq5gZ4TVzdC7VQR4Q2A6FKZMniRKcGcLc9rOzLa6D5BglQkZafuWeGk5 U0sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=heynQIj6; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12si9318025pgk.520.2018.11.19.07.58.22; Mon, 19 Nov 2018 07:58:37 -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=@google.com header.s=20161025 header.b=heynQIj6; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729906AbeKTCVp (ORCPT + 99 others); Mon, 19 Nov 2018 21:21:45 -0500 Received: from mail-vs1-f65.google.com ([209.85.217.65]:36765 "EHLO mail-vs1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729825AbeKTCVo (ORCPT ); Mon, 19 Nov 2018 21:21:44 -0500 Received: by mail-vs1-f65.google.com with SMTP id v205so18048586vsc.3 for ; Mon, 19 Nov 2018 07:57:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=9nI9EDei5NGcqe3JqwT0iOoVckuBXoqey9NpE1OlEpQ=; b=heynQIj6O4SVyC4gy/+l1sSnO3mvntoxLfoOPd8OJ9bmkA+yC3Z2IBl8/38lfKcIuF aRo3LfvjtdUu/uYuewCmbji0PM7l+Tq5tp0G8Idy5Pl+8Uur1bYvolyW0DoBfoHMgyPg /ux2x+aQepTXIcuGpE6LAp/6/GMMRi64xb25vFsJBMwWkJ4fIVawh3MaoPbBaVNrykz8 EkjLef5/ifRs/YjDkUtQa104wIhuk8jGJ/KXtHuWbrS1Vs+99YVvsJbUqngG5mzmTGMN /7B/UPC2IKp2U2s5NGepnaXVxEQ/q2KFQwaalRICQhvUueaKbiMnS49qJ0hoVbD9PzqN jHsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=9nI9EDei5NGcqe3JqwT0iOoVckuBXoqey9NpE1OlEpQ=; b=G9Zh1SANJpMdYKAQsyovBmVVkXehm9XQzpDwyuzZXQmFX5sZboNY1yojnqtoMMHACv lXLPTUp8G8nTWRxdTksYjaJgYWcnnGUTQ2QPDnC1KS3tqCu7Qq9qgd7B7cZ7+YPZhd32 1NbU0tgT4wd1QuBq2WMaWPud9kSJbhkKRpJa+QmD7+pOU3Vof6/r1CVdmwqt61KhF4sU 0QTGQp0XHyZzHSm3mANpPn7mw7Q25Kt6nyhGt13uBqfApnKnTxY5Op1N2AHhlh1EQTZh qq30iRi7KRypWHHtilDxEbHEPO6J6nkmhSmtkOVoUaznzP8hHsv0FCf7A/R60e6UWKCf KvEw== X-Gm-Message-State: AGRZ1gJmOF+8tlFnDjbIVQKvFDl9/QvBFdYhYZKceEVCfzg7NIHFAYmO UAo5nXJYnFtWTr6Pvl+jIQcDd2Qr8yQX3/qtxShqNg== X-Received: by 2002:a67:6cc1:: with SMTP id h184mr9443264vsc.149.1542643063333; Mon, 19 Nov 2018 07:57:43 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a67:f48d:0:0:0:0:0 with HTTP; Mon, 19 Nov 2018 07:57:42 -0800 (PST) In-Reply-To: References: <20181119103241.5229-1-christian@brauner.io> <20181119103241.5229-3-christian@brauner.io> From: Daniel Colascione Date: Mon, 19 Nov 2018 07:57:42 -0800 Message-ID: Subject: Re: [PATCH v1 2/2] signal: add procfd_signal() syscall To: Andy Lutomirski Cc: Christian Brauner , "Eric W. Biederman" , LKML , "Serge E. Hallyn" , Jann Horn , Andrew Morton , Oleg Nesterov , Aleksa Sarai , Al Viro , Linux FS Devel , Linux API , 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 Mon, Nov 19, 2018 at 7:45 AM, Andy Lutomirski wrote: > On Mon, Nov 19, 2018 at 2:33 AM Christian Brauner wrote: >> >> The kill() syscall operates on process identifiers. After a process has >> exited its pid can be reused by another process. If a caller sends a signal >> to a reused pid it will end up signaling the wrong process. This issue has >> often surfaced and there has been a push [1] to address this problem. >> >> A prior patch has introduced the ability to get a file descriptor >> referencing struct pid by opening /proc/. This guarantees a stable >> handle on a process which can be used to send signals to the referenced >> process. Discussion has shown that a dedicated syscall is preferable over >> ioctl()s. Thus, the new syscall procfd_signal() is introduced to solve >> this problem. It operates on a process file descriptor. >> The syscall takes an additional siginfo_t and flags argument. If siginfo_t >> is NULL then procfd_signal() behaves like kill() if it is not NULL it >> behaves like rt_sigqueueinfo. >> The flags argument is added to allow for future extensions of this syscall. >> It currently needs to be passed as 0. > > A few questions. First: you've made this work on /proc/PID, but > should it also work on /proc/PID/task/TID to send signals to a > specific thread? +1 >> + if (info) { >> + ret = __copy_siginfo_from_user(sig, &kinfo, info); >> + if (unlikely(ret)) >> + goto err; >> + /* >> + * Not even root can pretend to send signals from the kernel. >> + * Nor can they impersonate a kill()/tgkill(), which adds >> + * source info. >> + */ >> + ret = -EPERM; >> + if ((kinfo.si_code >= 0 || kinfo.si_code == SI_TKILL) && >> + (task_pid(current) != pid)) >> + goto err; > > Is the exception for signaling yourself actually useful here? All the signal functions exempt the current process from access checks. Whether that's useful or not (and I think it is), being inconsistent here would be wrong.