Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756515AbdLVU2b (ORCPT ); Fri, 22 Dec 2017 15:28:31 -0500 Received: from mail-oi0-f68.google.com ([209.85.218.68]:35597 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755458AbdLVU22 (ORCPT ); Fri, 22 Dec 2017 15:28:28 -0500 X-Google-Smtp-Source: ACJfBouBI0VN1BtRCKF6plsiTr6+o2VN7VU7nauaXb4yke5L6nHv5XKcIXBZo+fFJumGVycc8j7+EQ== Subject: Re: ptrace versus setuid changes in 4.14? To: Tom Horsley , linux-kernel@vger.kernel.org, Kees Cook References: <20171221091811.5bbb47db@tomh> From: Laura Abbott Cc: David Howells , Serge Hallyn , James Morris Message-ID: Date: Fri, 22 Dec 2017 12:28:25 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20171221091811.5bbb47db@tomh> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2417 Lines: 57 On 12/21/2017 06:18 AM, Tom Horsley wrote: > On my fedora 26 box with a 4.13 kernel, when a process > under ptrace control did an exec of a setuid program, > the program lost all of its setuid privileges and > ptrace could operate on it like a normal program. > > Experimental evidence seems to indicate that on > fedora 27 with a 4.14 kernel, ptrace cannot > do a PEEKDATA to read anything from the just > execed setuid program. (I get errno 5 - I/O error). > > Am I confused somehow, or did something really change > in this vicinity? > > It puts a real crimp in my fancy debug feature to > patch code into a setuid program to make it re-exec itself, > then detach from it. (I don't suppose we could get > a setoptions feature to tell the kernel to detach > from setuid programs automagically and let the debugger > know it is no longer in control of the process?) > Assuming this is https://bugzilla.redhat.com/show_bug.cgi?id=1528633 This is yet another victim of commit e37fdb785a5f95ecadf43b773c97f676500ac7b8 (refs/bisect/bad) Author: Kees Cook Date: Tue Jul 18 15:25:31 2017 -0700 exec: Use secureexec for setting dumpability The examination of "current" to decide dumpability is wrong. This was a check of and euid/uid (or egid/gid) mismatch in the existing process, not the newly created one. This appears to stretch back into even the "history.git" tree. Luckily, dumpability is later set in commit_creds(). In earlier kernel versions before creds existed, similar checks also existed late in the exec flow, covering up the mistake as far back as I could find. Note that because the commit_creds() check examines differences of euid, uid, egid, gid, and capabilities between the old and new creds, it would look like the setup_new_exec() dumpability test could be entirely removed. However, the secureexec test may cover a different set of tests (specific to the LSMs) than what commit_creds() checks for. So, fix this test to use secureexec (the removed euid tests are redundant to the commoncap secureexec checks now). Cc: David Howells Signed-off-by: Kees Cook Acked-by: Serge Hallyn Reviewed-by: James Morris Is it time to think about reverting? Thanks, Laura