Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp6415041imd; Wed, 31 Oct 2018 11:18:07 -0700 (PDT) X-Google-Smtp-Source: AJdET5dzraMZVUe7p5SC15EkhJXa4/R/o9f/kMC38vtShRwXO4qYuwsofjxhoOZH6OtFAm6nudPZ X-Received: by 2002:a17:902:6bc1:: with SMTP id m1-v6mr4575377plt.34.1541009887488; Wed, 31 Oct 2018 11:18:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541009887; cv=none; d=google.com; s=arc-20160816; b=ri0PGjn+IUwZDwCokDVvtmU62Y8yQYSpmJWutK5nGFh4GS+/7dXc5RFTEmXZ+Grs1x OH5qOYeeYW5J1D8jPIJQDqXa/oymQhsZx1gt9Zt1zf3KuHCK4rsa/fS0pNaLwG/DY4Uw VcWnH3mAGipsSAiHWPxMQiHC5D/i9lE64c88M3p9ELGnWh8rUrSv0s9QoyMvg678EZtm NHQhbyBxgtYlyq0nQMCT0Dlu5Cgs/HLBNeZDh3xG2XS0OFhH5+0TWTnxicQxNTaBnauH U/WoMzlsB7ZeXC4GKy7IPoRNTb8mykNpmS+zbhKFP0LYISosY2AuAfeKNo16A4ssIfbG /kng== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=sVaziTIpyUOUhUsbSepg0EQX77ZWmo8ScVcNxR9osZ0=; b=mQ2ygaYn8PIAss7S7vfGrJUzAmw4/dUgw+ESGrMeztQbI1veJcxvO55+6C7J589l8T VvYJQmk0Vx8nYUZ07eR2vcRdctyT/4IrOYa/tIRKXgUHN1CX8w27/Ksoj6l2GBuVZ6lX fskAIOpdgGqYQ08pgm5wlspA/MTrVxZQjU6nYc5A9Kj467W++bykxxw0CGApbrSgD4v4 +dHRHsoascEX6NH279PPCkkp5ojKZinZZfjT/t3vAsulBn+5d7DRmSbfoBeqwUPGcSl5 Z/Ssj+/2U5W4uowfB914bKC4JgHuXT+h9S7mfyEcMlpwydaIEk1KYP4+wQE+KPsEcAwQ PYUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b="xgijD/OV"; 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 r13-v6si18375009pgk.127.2018.10.31.11.17.50; Wed, 31 Oct 2018 11:18:07 -0700 (PDT) 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=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b="xgijD/OV"; 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 S1730069AbeKADQb (ORCPT + 99 others); Wed, 31 Oct 2018 23:16:31 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:43226 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729206AbeKADQb (ORCPT ); Wed, 31 Oct 2018 23:16:31 -0400 Received: by mail-qt1-f195.google.com with SMTP id q41-v6so18187283qtq.10 for ; Wed, 31 Oct 2018 11:17:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho-ws.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=sVaziTIpyUOUhUsbSepg0EQX77ZWmo8ScVcNxR9osZ0=; b=xgijD/OVOgAc0SQX/5mYIq06iHb6LjH6PBZ6R82PCvcdT59FUdhYGYeDjUOFS+aQ1f 4mCH8fRJ1OfFQm+0rswolmbp/Fx+59FafilfqEmmZEA8Xmx4301ko1ym5md1QVVaJR8z 2I+9XakAe7EIP9kwqh6ekRsKUFta9tmeyQq/9/BQMY6VerRnArbyEAx3KjMlW5Qf/uGV AXNvYqV2B4soSquR23dSapdS86ObzIWz1O87OoODPbBnq5CEAGh8f2t8aZbRDHEPejRp +Sfi3uibi9SuZJAIaaWRPaA8z+seY3ej/aWIEwZQ7t0N5M6Rx3a3yp0uPIKutHbSbDqN O5uw== 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:in-reply-to:user-agent; bh=sVaziTIpyUOUhUsbSepg0EQX77ZWmo8ScVcNxR9osZ0=; b=Z0LBMqDIHFH7eJG61TSXbYfDLOlpszBGVoRFyfs+qdON90BI052xHWyoBYE29HLyH2 QcwsOjRez8lfLz+5r0RGWyjFhG1AKCWI8xDVRwifVUuXcAYzJv17nt6pOcNkzBJGPmVN 5Rz934Yhf1zGVg2GHxUUKm3AC+k/n+FWdJMlH7M15wjmibJDO277sJcR2xCgtd27y01G kMojxcDmiqdbk9MmQFpvAYyEoa0C/JcSgk841ldBItaALFyXOpMy3SENLqVjkZePhQwQ QpZXyP+gGZsKiBQwwy8zMHw4fDFx1UMyrwS1UCpy7MVbY01hAkz8/hTf0dAtEenWgBCO Ly9w== X-Gm-Message-State: AGRZ1gKIQvK+nC6E2nJ7/N53EW8kjHSFcqzBchbufiG9FKdPuP24maVs +I3XdadoCEDmoqdrWi57Ngp53EnuU5UTVw== X-Received: by 2002:ac8:2381:: with SMTP id q1-v6mr3811219qtq.322.1541009841894; Wed, 31 Oct 2018 11:17:21 -0700 (PDT) Received: from cisco ([173.38.117.87]) by smtp.gmail.com with ESMTPSA id o49sm6702779qtf.60.2018.10.31.11.17.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Oct 2018 11:17:20 -0700 (PDT) Date: Wed, 31 Oct 2018 12:17:17 -0600 From: Tycho Andersen To: Daniel Colascione Cc: linux-kernel , Tim Murray , Joel Fernandes , Suren Baghdasaryan , Aleksa Sarai , Christian Brauner , "Eric W. Biederman" , Kees Cook , Oleg Nesterov Subject: Re: [PATCH v3] Implement /proc/pid/kill Message-ID: <20181031181717.GD2180@cisco> References: <20181029221037.87724-1-dancol@google.com> <20181031155912.45088-1-dancol@google.com> <20181031175448.GC2180@cisco> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 31, 2018 at 06:00:49PM +0000, Daniel Colascione wrote: > On Wed, Oct 31, 2018 at 5:54 PM, Tycho Andersen wrote: > > Why not just use an ioctl() like Jann suggested instead of this big > > security check? Then we avoid the whole setuid writer thing entirely, > > Don't you think a system call would be better than a new ioctl? We already have a kill() system call :) > With either an ioctl or a new system call, though, the shell would > need a helper program to use the facility, whereas with the existing > approach, the shell can use the new facility without any additional > binaries. ...and a binary to use it! The nice thing about an ioctl is that it avoids this class of attacks entirely. > > and we can pass the fd around if we want to. > > You can pass the FD around today --- specifically, you just pass the > /proc/pid directory FD, not the /proc/pid/kill FD. The /proc/pid > directory FD acts as a process handle. (It's literally a reference to > a struct pid.) Anyone who receives one of these process handle FDs and > who wants to use the corresponding kill file can open the kill fd with > openat(2). What you can't do is pass the /proc/pid/kill FD to another > security context and use it, but when would you ever want to do that? Perhaps I don't have a good imagination, because it's not clear to me when I'd ever use this from a shell instead of the kill binary, either. Using this from the shell is still racy, because if I do something like: echo 9 > /proc/$pid/kill There's exactly the same race that there is with kill, that $pid might be something else. Of course I could do some magic with bind mounts or my pwd or something to keep it alive, but I can already do that today with kill. I can understand the desire to have a race free way to do this, but "it must use write(2)" seems a little unnecessary, given that the shell use case isn't particularly convincing to me. Tycho