Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751611AbdFGMXX (ORCPT ); Wed, 7 Jun 2017 08:23:23 -0400 Received: from mx2.suse.de ([195.135.220.15]:39164 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751618AbdFGMWD (ORCPT ); Wed, 7 Jun 2017 08:22:03 -0400 Subject: Re: [PATCH 00/26] Fixing wait, exit, ptrace, exec, and CLONE_THREAD To: "Eric W. Biederman" Cc: linux-kernel@vger.kernel.org, Kees Cook , Roland McGrath , linux-api@vger.kernel.org, Linux Containers , Oleg Nesterov , David Howells , Al Viro , Thomas Gleixner , Linus Torvalds , Ingo Molnar , "Michael Kerrisk (man-pages)" References: <877f0pym71.fsf@xmission.com> <87ink8vxkf.fsf@xmission.com> From: Aleksa Sarai Message-ID: <6168b181-c57d-babb-e700-bdc30186a22a@suse.de> Date: Wed, 7 Jun 2017 22:21:52 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <87ink8vxkf.fsf@xmission.com> 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: 1471 Lines: 36 On 06/07/2017 09:36 PM, Eric W. Biederman wrote: >>> Another easy entry point is to see that a multi-threaded setuid won't >>> change the credentials on a zombie thread group leader. Which can allow >>> sending signals to a process that the credential change should forbid. >>> This is in violation of posix and the semantics we attempt to enforce in >>> linux. >> >> I might be completely wrong on this point (and I haven't looked at the patches), >> but I was under the impression that multi-threaded set[ug]id was implemented in >> userspace (by glibc's nptl(7) library that uses RT signals internally to get >> each thread to update their credentials). And given that, I wouldn't be >> surprised (as a user) that zombie threads will have stale credentials (glibc >> isn't running in those threads anymore). >> >> Am I mistaken in that belief? > > Would you be surprised if you learned that if your first thread > exits, it will become a zombie and persist for the lifetime of your > process? > > Furthermore all non-thread specific signals will permission check > against that first zombie thread. Ah okay, so it really is a matter of Linux's threadgroup semantics just not being "right" on a more fundamental level than nptl. > Which I think makes this surprising even if you know that setuid is > implemented in userspace. Quite surprising, thanks for the explanation. -- Aleksa Sarai Software Engineer (Containers) SUSE Linux GmbH https://www.cyphar.com/