Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1835053imu; Sun, 18 Nov 2018 09:46:33 -0800 (PST) X-Google-Smtp-Source: AJdET5divYIWuGBgGw5PDNNs1mzsn7L5Nz3Y00Ja+pHA5lShI5iFzOXmng7982MdcVg+NK8Q7uJb X-Received: by 2002:a17:902:2aaa:: with SMTP id j39mr11052411plb.335.1542563193130; Sun, 18 Nov 2018 09:46:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542563193; cv=none; d=google.com; s=arc-20160816; b=BfbBri6gW9D1iLO/UdIcxRujzRIma1y+w5aYj2FLcI4DJ426b8SFfRh5SET17ej7yp sZa5nTRjVIJwE+32FVcv3ii2Tv76o0IyuWo5DNTq6o4pU7RYIoCLRNkEOE8KUH010mOJ YKN0pvTz2d5qo9gL/cS7pHLMP9h70/oVKxMZoNh+OALmXn8rgXIOS+3XYczpn1COQf8i bFhF9VjVEgrximA1LVPxoKuhwxpxD3Mwg/oonyasJnLZ1OY97cAgCjT/s0NnMu+DlZC3 2O/GgaVx/Wh7dx4uF3ZKQkJnRI0U7V3cj17j+wnpnMaRANUt2+tlIOnzVA3LIdh3PlXo ZOfw== 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=9Z5vjBgTJgsrcJtePr3i81CvY22tsqayfhvS5CV4yc8=; b=WS7bPZvhgzbGGy5m9M18RrEmazMGq61YxzVfcclB5QwrA4lLQU5rCasEOfrs6iIuGQ IOroautZa3b7Mrr1MqVCJ/bGGae37dHVLubmQBdqBK4DN0Xeo6TH11N6a2QuBjjxKeUU WffrQ37WAr0gEPwJ5R0gnM/RELqfZHV9Ob1+G1/JJ8WS+wVJ0W9ApHS8RDieqX2Hpbcf fn7fNfL9C/l0MSCd9weh/KUdswPoL2ahK5S3gpgK4sZxiUZQ3Nxgy+Am5tre5sYn+Wwm np9XZua+lCBMMaH/KvSwQv5uMUzkOgAIrbQU2Hx37sxRshLlZRgAIwLu+g61nFJgirmd C+MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IURlL1tv; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p187-v6si41555215pfb.127.2018.11.18.09.46.18; Sun, 18 Nov 2018 09:46:33 -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=@kernel.org header.s=default header.b=IURlL1tv; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727173AbeKSEGZ (ORCPT + 99 others); Sun, 18 Nov 2018 23:06:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:41678 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726366AbeKSEGZ (ORCPT ); Sun, 18 Nov 2018 23:06:25 -0500 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F279820869 for ; Sun, 18 Nov 2018 17:45:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542563132; bh=MlYcTA+pxCgRlLmkq7p10271XiJ9hbticyJ1njnyFsQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=IURlL1tvEjBqbGeborq7K5QglZ4Wlv0EaaB/ebnCijfgZ167g5ONgZHGjr0qVxday 7zQ0I99mjgUbu37x+8XTTJpVeeRBEuqUQ+eUlS5bqeemZzzTUkNYOiyW2EwziNixnf Bt3IMJKe8GXacD9JYES7ahdEzQ+T4yxU6unS9o/M= Received: by mail-wm1-f43.google.com with SMTP id s11so3092095wmh.1 for ; Sun, 18 Nov 2018 09:45:31 -0800 (PST) X-Gm-Message-State: AA+aEWZQmAVtwEjCyAe+lWpeGjztOwcoZfkSAINsIWvFOEvZGH6uVaEW hsfo3VciIYCGXlHQo55P04U8vzywqY6wunIhFT9xlw== X-Received: by 2002:a7b:ce11:: with SMTP id m17mr5018311wmc.74.1542563130440; Sun, 18 Nov 2018 09:45:30 -0800 (PST) MIME-Version: 1.0 References: <20181118111751.6142-1-christian@brauner.io> <875zwu46z1.fsf@xmission.com> In-Reply-To: <875zwu46z1.fsf@xmission.com> From: Andy Lutomirski Date: Sun, 18 Nov 2018 09:45:18 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] proc: allow killing processes via file descriptors To: "Eric W. Biederman" Cc: Daniel Colascione , Andrew Lutomirski , Christian Brauner , LKML , "Serge E. Hallyn" , Jann Horn , Andrew Morton , Oleg Nesterov , Aleksa Sarai , Al Viro , Linux FS Devel , Linux API , Tim Murray , 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 Sun, Nov 18, 2018 at 9:43 AM Eric W. Biederman wrote: > > Daniel Colascione writes: > > > On Sun, Nov 18, 2018 at 9:13 AM, Andy Lutomirski wrote: > >> On Sun, Nov 18, 2018 at 8:29 AM Daniel Colascione wrote: > >>> > >>> On Sun, Nov 18, 2018 at 8:17 AM, Andy Lutomirski wrote: > >>> > On Sun, Nov 18, 2018 at 7:53 AM Daniel Colascione wrote: > >>> >> > >>> >> On Sun, Nov 18, 2018 at 7:38 AM, Andy Lutomirski wrote: > >>> >> > I fully agree that a more comprehensive, less expensive API for > >>> >> > managing processes would be nice. But I also think that this patch > >>> >> > (using the directory fd and ioctl) is better from a security > >>> >> > perspective than using a new file in /proc. > >>> >> > >>> >> That's an assertion, not an argument. And I'm not opposed to an > >>> >> operation on the directory FD, now that it's clear Linus has banned > >>> >> "write(2)-as-a-command" APIs. I just insist that we implement the API > >>> >> with a system call instead of a less-reliable ioctl due to the > >>> >> inherent namespace collision issues in ioctl command names. > >>> > > >>> > Linus banned it because of bugs iike the ones in the patch. > >>> > >>> Maybe: he didn't provide a reason. What's your point? > >> > >> My point is that an API that involves a file like /proc/PID/kill is > >> very tricky to get right. Here are some considerations: > > > > Moot. write(2) for this interface is off the table anyway. The right > > approach here is a system call that accepts a /proc/pid directory file > > descriptor, a signal number, and a signal information field (as in > > sigqueue(2)). > > If we did not have the permission check challenges and could perform > the permission checks in open, write(2) would be on the table. > Performing write(2) would only be concrend about data. > > Unfortunately we have setresuid and exec which make that infeasible > for the kill operations. setresuid() should be irrelevant. If you had permission to kill a process and the process calls setresuid(), you should still have permission to kill it. For execve(), we could make execve() invalidate the fd. (See other email.)