From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751371AbdE3Q3S (ORCPT ); Tue, 30 May 2017 12:29:18 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:34833 "EHLO relay2-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751184AbdE3Q3Q (ORCPT ); Tue, 30 May 2017 12:29:16 -0400 X-Originating-IP: 72.66.113.207 Subject: Re: [kernel-hardening] Re: [PATCH v7 2/2] security: tty: make TIOCSTI ioctl require CAP_SYS_ADMIN To: Alan Cox References: <20170529213800.29438-1-matt@nmatt.com> <20170529213800.29438-3-matt@nmatt.com> <20170529232640.16211960@alans-desktop> <3738951f-7a4a-b37f-c695-21a2fcd45f76@schaufler-ca.com> <0e078ce7-5b62-f27c-3920-efc2ffdf342b@nmatt.com> <20170530132427.016053da@alans-desktop> Cc: Casey Schaufler , Boris Lukashev , Greg KH , "Serge E. Hallyn" , Kees Cook , kernel-hardening@lists.openwall.com, linux-security-module , linux-kernel From: Matt Brown Message-ID: <2ab8580e-bf8e-21bd-6bfa-33e5fa82400b@nmatt.com> Date: Tue, 30 May 2017 12:28:59 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170530132427.016053da@alans-desktop> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/30/17 8:24 AM, Alan Cox wrote: > Look there are two problems here > > 1. TIOCSTI has users I don't see how this is a problem. > > 2. You don't actually fix anything > > The underlying problem is that if you give your tty handle to another > process which you don't trust you are screwed. It's fundamental to the > design of the Unix tty model and it's made worse in Linux by the fact > that we use the tty descriptor to access all sorts of other console state > (which makes a ton of sense). > > Many years ago a few people got this wrong. All those apps got fixes back > then. They allocate a tty/pty pair and create a new session over that. > The potentially hostile other app only gets to screw itself. > Many years ago? We already got one in 2017, as well as a bunch last year. See: https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=tiocsti > If it was only about TIOCSTI then your patch would still not make sense > because you could use on of the existing LSMs to actually write yourself > some rules about who can and can't use TIOCSTI. For that matter you can > even use the seccomp feature today to do this without touching your > kernel because the ioctl number is a value so you can just block ioctl > with argument 2 of TIOCSTI. > Seccomp requires the program in question to "opt-in" so to speak and set certain restrictions on itself. However as you state above, any TIOCSTI protection doesn't matter if the program correctly allocates a tty/pty pair. This protections seeks to protect users from programs that don't do things correctly. Rather than killing bugs, this feature attempts to kill an entire bug class that shows little sign of slowing down in the world of containers and sandboxes. > So please explain why we need an obscure kernel config option that normal > users will not understand which protects against nothing and can be > done already ? > > Alan >