Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1808292imu; Sun, 18 Nov 2018 09:14:41 -0800 (PST) X-Google-Smtp-Source: AJdET5c+pQ64kxTIOvWTkjzoekvTm2phJZRe29QOCsXgRVeoOkQHQ9KMusxbIA9djR69MZa+4L9r X-Received: by 2002:a17:902:4025:: with SMTP id b34-v6mr19285332pld.318.1542561281006; Sun, 18 Nov 2018 09:14:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542561280; cv=none; d=google.com; s=arc-20160816; b=nXH2ypYtUu2KcE3cPe4YIK7Cc3ciGHCJTJuRxeIsAm3eJPaekVLLNekfyuL3K9lSNw a03ch4H7aZtwPOJwZ1lO85VJe9wxmTlgmnYQ0XAaGIqNBqpe9G7y0ktXTuzTYgwCWju9 yPOF/FFH4q9GTVbFZF0vdEZMaBMA1p/x25kIhJm4I6uqperxyM6ep5SXWLqSaqOErvAF 3vZaJvOvoZQ/V6FdRwFI33ja9LApBLfxZxcx8edoU2tSPhQ8/qZBn1W+Y7IiVKfutTH9 aFSopE4s/XwYOpHNjrNAMeLUiuye6Rav77iETCNrsRkq2O5++jOq4P/y20zs48/gk5R2 Tr0Q== 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=dUyTCV3fWbRuO+Jg1CaBHS0UzXXOHp1MG9NpL36V7hk=; b=z4lbYHIG3IHN/O3Odj11ONySfMnhi5/lfZDW5VzmAAmkrZe/LdU6ZI+c1wWIjzNH9e UhrU8hG4xUInfTyxucPtOvwdr9wntPfRAo5qD9KMDWBLXwwFi17UnXGHRkGBKXCUOBqD 4dy6vtNcB9Ew3fIF7uUzGFMWCKEqAbJXPaBrsDq+aFrzyZE8+hPVzMmPxSAw/oRTKH21 hhHqaG9+65xopYDlaXDrYWALJdhZKs8FjTcCwa3p/9kadn+IhbK/HXgJaYrpKTlm5NmK wAReiDSSo+o/25sr1BymGxk9cdLpek/Z4rNx4mYcUp8SVzU2+MfXff6sV1aIrg7bxH0e wKkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="2Vft/71X"; 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 u3-v6si3300301pls.137.2018.11.18.09.14.25; Sun, 18 Nov 2018 09:14:40 -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="2Vft/71X"; 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 S1727246AbeKSDeg (ORCPT + 99 others); Sun, 18 Nov 2018 22:34:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:54180 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726746AbeKSDef (ORCPT ); Sun, 18 Nov 2018 22:34:35 -0500 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 B26872145D for ; Sun, 18 Nov 2018 17:13:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542561227; bh=cBlCzpwFGB16YMGG5gFTK82IzA0QCWH/ndqovWXyGYk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=2Vft/71XBTMAajbbdcVqFSHSEGwtSJiD3C75g15V1psXbbd1rjK4K27kwILtMfjWI gClnRMt4Y1s5Aj0AjwYxCSAFi8Y5D5Salj7t2/2O+IhHSNGjY3mdkfXR6uJzN5NElj 0JZheZ0mvBVjicxuaZjRgB6Jntk2ftUPajL2nrfg= Received: by mail-wm1-f49.google.com with SMTP id k198so2598068wmd.3 for ; Sun, 18 Nov 2018 09:13:46 -0800 (PST) X-Gm-Message-State: AGRZ1gIkUvm9BxKUNtDSJ1u1bE5h20CcRLdLpYcrhNyKp+JnI3PXWcuJ 3wX0wcvYi5GWl2LD6o0UfvMxfO3XXYJrmyjElxBjLg== X-Received: by 2002:a1c:f112:: with SMTP id p18mr4335845wmh.83.1542561225004; Sun, 18 Nov 2018 09:13:45 -0800 (PST) MIME-Version: 1.0 References: <20181118111751.6142-1-christian@brauner.io> In-Reply-To: From: Andy Lutomirski Date: Sun, 18 Nov 2018 09:13:33 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] proc: allow killing processes via file descriptors To: Daniel Colascione Cc: Andrew Lutomirski , 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 , 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 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: 1. The .write handler for the file must not behave differently depending on current. So we can't check the caller's creds. (There are legacy things that are generally buggy that look at current's creds in write handlers. They're legacy, and they're almost universally at least a little bit buggy, and many have been exploitable.) 2. Even if we have ioctl() or a new syscall on /proc/PID/kill, we at least have to define whether *opening* kill checks any credentials. It probably shouldn't, since I don't see what the semantics should be. 3. The current Linux kill_pid stuff doesn't take a cred parameter, so it's not so easy to check f_cred even if we wanted to. So the simplest implementation using /proc/PID/kill would be for .open to do essentially nothing and for ioctl or a new syscall to check credentials as usual. But this seems to have no technical advantage over just using /proc/PID itself, and it's a good deal slower, as it requires an open/close cycle. Now if we had an ioctlat() API, maybe it would make sense. But we don't, and I think it would be a bit crazy to add one. --Andy