Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1034127ybh; Tue, 10 Mar 2020 13:12:27 -0700 (PDT) X-Google-Smtp-Source: ADFU+vssKTXYIlPZ8zHd6zyOyDL/p3zCp/4I0/Pg9DGiGu+aJeZshZIFKKjoMgJ4573uBmfNkxo+ X-Received: by 2002:aca:3544:: with SMTP id c65mr2382039oia.160.1583871147464; Tue, 10 Mar 2020 13:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583871147; cv=none; d=google.com; s=arc-20160816; b=U1V+GBPJsKsuljS48QBFVExte8Wbyg3+pWpn/PHOuDqwvc/lq/L2bT1gtNECMnFPEu v/U2TQGs8MayVAa/+fakrTHYFvVGqQyRMyEAKrs8gIIVwFT9J2DOiWpo09ltAndXASR5 iIPqnD8PmwaGQv6QCmjWhd1YKVIVj/5m0vrl92KUhv1pb8MKvVY7v7zcV0RFc4toKSC+ OK9RdGRrmKx5L/SCdOEoUkDHsp5ZrmZbiKUi1UciJozXFoVO8XEiOQcC+gfK8St5ZCBw y3ozphgYHCRqGXc34zzTrfz68m5CwDtT/U2GefGNrGPFUSl9rQ9kmEZVAOwuaExUBHcJ nqFQ== 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=K3vOtJHo8wa+L0rub3QWCJZcPdNt+IghtsNXVMZnf9o=; b=YehrTQy9/y4mMnya1h1aON9pK3MRRoYb0/MGYsN5xY/QpvHFOV8YVE+2rDxucLxzy0 ODZdWe3StLhzxtEpI61IDnkpYVpyuXB+S1YqCw/D1pCsFkmWzhNtaB0wQXfCPX05T42A yG5lS98BpHcmyKRPCMfEKDzDAv30NQSjG6Q7pUeT+foYkFahbf98ck9U5FlwPryQO6r5 eXjdfQmjE3l+1gFPxDfgU4+sGq+3H/OuxsXLkpuRrTnP2X2quddkLROMpC3LPZrOeomn ayRbSrb3umYZlHDSyduR2x1jaaP+/Q+3S3PvFVNe8Gq0McX4R3OoZwi1HsKrgRi+mDno hnIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="m/uY0trW"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h9si8245427oti.155.2020.03.10.13.12.14; Tue, 10 Mar 2020 13:12:27 -0700 (PDT) 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=@google.com header.s=20161025 header.b="m/uY0trW"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727124AbgCJUL1 (ORCPT + 99 others); Tue, 10 Mar 2020 16:11:27 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:34809 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726604AbgCJUL1 (ORCPT ); Tue, 10 Mar 2020 16:11:27 -0400 Received: by mail-oi1-f194.google.com with SMTP id g6so15291040oiy.1 for ; Tue, 10 Mar 2020 13:11:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=K3vOtJHo8wa+L0rub3QWCJZcPdNt+IghtsNXVMZnf9o=; b=m/uY0trWMAr4FqVX9i9CSnmjQPURPHBOvx6pe5fEMWJ/e5Tk2vaRLevTLCVkqDclV/ 9U8dYbHfSmT1VryWEJSOssyM6R8QAQdwr6JjSl1yllVynLdhE+EqANllz3GJD9T5HKJx 5o1mk82fLBEMHb75zYy13h8oqLlVg+LksCTipqO4JL4jJKJTlWmW0OpW3rTbODkp5lQD o6zv+ZZn4FMnxGec2LxSQUD3vMa8YdhAk6f9V4RcuRPJetmizxPCHUgu3hzhD81e8CVo Qx3HgSr4qFdSi9ME0sT7JSnsZUpOvPvCvsVRKmVC565oSKAhwb9Ar6hsa+h/gil57td2 EUFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=K3vOtJHo8wa+L0rub3QWCJZcPdNt+IghtsNXVMZnf9o=; b=ZQz/kYUWmx5uXxZgT4LRmYiPf1ZjsGedyuzmVmiIWq7P1PX6MEUaHrJqzW5F1Sew8t wXk6atlReUdlNS5+oDA6Djrg99T5Kd4ByktFam+e394sTcJ5mxREDWCQR8ZJkxUk71/+ KleAJSxmczGT8az/MEWJwxYYm+qPPpAoFJ4b9TUmOFQNlVZwe3F8ADm3RNTrftNBVv8R a3XjFtcKhtiLlFIVihO+6vz+IiyfDVrE4Rdxsm5ctUTJwX8RDHaZVQ8Ye/GcHvXo2+TO u9uUpj56q5+8HWWGRXHKQq/x0yWTWUqcAVLRQPjOiH7FPhI8PG5Rfq1a6LDZ06X/Zmve cpIA== X-Gm-Message-State: ANhLgQ20vA03wDLMI7AJRdc5+sR6Vud5nuJ6nxSGrHDujboY/d1/hMPr Hz/OQ+0aSryI6AoL9nq+RB0r1sDTwrOTMU0RNLtXiw== X-Received: by 2002:aca:bac1:: with SMTP id k184mr2032952oif.157.1583871086051; Tue, 10 Mar 2020 13:11:26 -0700 (PDT) MIME-Version: 1.0 References: <87r1y8dqqz.fsf@x220.int.ebiederm.org> <87tv32cxmf.fsf_-_@x220.int.ebiederm.org> <87v9ne5y4y.fsf_-_@x220.int.ebiederm.org> <87eeu25y14.fsf_-_@x220.int.ebiederm.org> <20200309195909.h2lv5uawce5wgryx@wittgenstein> <877dztz415.fsf@x220.int.ebiederm.org> <20200309201729.yk5sd26v4bz4gtou@wittgenstein> <87k13txnig.fsf@x220.int.ebiederm.org> <20200310085540.pztaty2mj62xt2nm@wittgenstein> <87wo7svy96.fsf_-_@x220.int.ebiederm.org> <87k13sui1p.fsf@x220.int.ebiederm.org> In-Reply-To: From: Jann Horn Date: Tue, 10 Mar 2020 21:10:59 +0100 Message-ID: Subject: Re: [PATCH] pidfd: Stop taking cred_guard_mutex To: "Eric W. Biederman" Cc: Christian Brauner , Bernd Edlinger , Kees Cook , Jonathan Corbet , Alexander Viro , Andrew Morton , Alexey Dobriyan , Thomas Gleixner , Oleg Nesterov , Frederic Weisbecker , Andrei Vagin , Ingo Molnar , "Peter Zijlstra (Intel)" , Yuyang Du , David Hildenbrand , Sebastian Andrzej Siewior , Anshuman Khandual , David Howells , James Morris , Greg Kroah-Hartman , Shakeel Butt , Jason Gunthorpe , Christian Kellner , Andrea Arcangeli , Aleksa Sarai , "Dmitry V. Levin" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "stable@vger.kernel.org" , "linux-api@vger.kernel.org" , Arnd Bergmann , Sargun Dhillon 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 Tue, Mar 10, 2020 at 9:00 PM Jann Horn wrote: > On Tue, Mar 10, 2020 at 8:29 PM Eric W. Biederman wrote: > > Jann Horn writes: > > > On Tue, Mar 10, 2020 at 7:54 PM Eric W. Biederman wrote: > > >> During exec some file descriptors are closed and the files struct is > > >> unshared. But all of that can happen at other times and it has the > > >> same protections during exec as at ordinary times. So stop taking the > > >> cred_guard_mutex as it is useless. > > >> > > >> Furthermore he cred_guard_mutex is a bad idea because it is deadlock > > >> prone, as it is held in serveral while waiting possibly indefinitely > > >> for userspace to do something. [...] > > > If you make this change, then if this races with execution of a setuid > > > program that afterwards e.g. opens a unix domain socket, an attacker > > > will be able to steal that socket and inject messages into > > > communication with things like DBus. procfs currently has the same > > > race, and that still needs to be fixed, but at least procfs doesn't > > > let you open things like sockets because they don't have a working > > > ->open handler, and it enforces the normal permission check for > > > opening files. > > > > It isn't only exec that can change credentials. Do we need a lock for > > changing credentials? [...] > > If we need a lock around credential change let's design and build that. > > Having a mismatch between what a lock is designed to do, and what > > people use it for can only result in other bugs as people get confused. > > Hmm... what benefits do we get from making it a separate lock? I guess > it would allow us to make it a per-task lock instead of a > signal_struct-wide one? That might be helpful... But actually, isn't the core purpose of the cred_guard_mutex to guard against concurrent credential changes anyway? That's what almost everyone uses it for, and it's in the name...