From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adam Borowski Subject: Re: [PATCH RESEND v5 0/5] namei: vfs flags to restrict path resolution Date: Thu, 25 Apr 2019 15:22:49 +0200 Message-ID: <20190425132249.GA26669@angband.pl> References: <20190320143717.2523-1-cyphar@cyphar.com> <20190325130429.dbrgjxnvq3w5cpb3@yavin> <20190424153806.64qkkmkudzodxnz2@yavin> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Content-Disposition: inline In-Reply-To: <20190424153806.64qkkmkudzodxnz2@yavin> Sender: linux-kernel-owner@vger.kernel.org To: Aleksa Sarai Cc: Kees Cook , Andy Lutomirski , Al Viro , Jeff Layton , "J. Bruce Fields" , Arnd Bergmann , David Howells , Eric Biederman , Jann Horn , Christian Brauner , David Drysdale , Tycho Andersen , Linux Containers , Linux FS Devel , Linux API , Andrew Morton , Alexei Starovoitov , Chanho Min , Oleg Nesterov , Aleksa Sarai List-Id: linux-arch.vger.kernel.org On Thu, Apr 25, 2019 at 01:38:06AM +1000, Aleksa Sarai wrote: > * openat(2) ignores unknown flags, meaning that old kernels will ignore > new programs trying to use O_THISROOT and might end up causing > security issues. Yes, it'd be trivial to check whether the new O_* > flags are supported at start-up, but I think a security feature > shouldn't have a foot-gun associated with it. In fact, I didn't know > openat(2) ignored unknown flags until I wrote this patchset -- I > doubt many other userspace developers do either. For this reason, I propose every new syscall that has flags to follow a bitmask scheme, where any flag assigned a bit in the upper half returns EOPNOTSUPP when called on an old kernel. That would allow defining which flags can be safely ignored and which can't. It otherwise takes major hacks to implement a fail-if-not-supported flag while keeping compat with old kernels. For example, for mmap(), MAP_SHARED has been duplicated as MAP_SHARED_VALIDATE just to allow an unrelated flag (MAP_SYNC) to fail on old kernels. Meow! -- ⢀⣴⠾⠻⢶⣦⠀ ⣾⠁⢰⠒⠀⣿⡁ Imagine there are bandits in your house, your kid is bleeding out, ⢿⡄⠘⠷⠚⠋⠀ the house is on fire, and seven giant trumpets are playing in the ⠈⠳⣄⠀⠀⠀⠀ sky. Your cat demands food. The priority should be obvious... From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from tartarus.angband.pl ([54.37.238.230]:36176 "EHLO tartarus.angband.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726120AbfDYNZf (ORCPT ); Thu, 25 Apr 2019 09:25:35 -0400 Date: Thu, 25 Apr 2019 15:22:49 +0200 From: Adam Borowski Subject: Re: [PATCH RESEND v5 0/5] namei: vfs flags to restrict path resolution Message-ID: <20190425132249.GA26669@angband.pl> References: <20190320143717.2523-1-cyphar@cyphar.com> <20190325130429.dbrgjxnvq3w5cpb3@yavin> <20190424153806.64qkkmkudzodxnz2@yavin> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190424153806.64qkkmkudzodxnz2@yavin> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Aleksa Sarai Cc: Kees Cook , Andy Lutomirski , Al Viro , Jeff Layton , "J. Bruce Fields" , Arnd Bergmann , David Howells , Eric Biederman , Jann Horn , Christian Brauner , David Drysdale , Tycho Andersen , Linux Containers , Linux FS Devel , Linux API , Andrew Morton , Alexei Starovoitov , Chanho Min , Oleg Nesterov , Aleksa Sarai , Linus Torvalds , LKML , linux-arch Message-ID: <20190425132249.jZfhXCeI5ZvTdLt1WcoGvPxApusSnL2DvNwSVHmg8rw@z> On Thu, Apr 25, 2019 at 01:38:06AM +1000, Aleksa Sarai wrote: > * openat(2) ignores unknown flags, meaning that old kernels will ignore > new programs trying to use O_THISROOT and might end up causing > security issues. Yes, it'd be trivial to check whether the new O_* > flags are supported at start-up, but I think a security feature > shouldn't have a foot-gun associated with it. In fact, I didn't know > openat(2) ignored unknown flags until I wrote this patchset -- I > doubt many other userspace developers do either. For this reason, I propose every new syscall that has flags to follow a bitmask scheme, where any flag assigned a bit in the upper half returns EOPNOTSUPP when called on an old kernel. That would allow defining which flags can be safely ignored and which can't. It otherwise takes major hacks to implement a fail-if-not-supported flag while keeping compat with old kernels. For example, for mmap(), MAP_SHARED has been duplicated as MAP_SHARED_VALIDATE just to allow an unrelated flag (MAP_SYNC) to fail on old kernels. Meow! -- ⢀⣴⠾⠻⢶⣦⠀ ⣾⠁⢰⠒⠀⣿⡁ Imagine there are bandits in your house, your kid is bleeding out, ⢿⡄⠘⠷⠚⠋⠀ the house is on fire, and seven giant trumpets are playing in the ⠈⠳⣄⠀⠀⠀⠀ sky. Your cat demands food. The priority should be obvious...