From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22A65C76199 for ; Sun, 16 Feb 2020 14:12:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EFFC02086A for ; Sun, 16 Feb 2020 14:12:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728300AbgBPOMm (ORCPT ); Sun, 16 Feb 2020 09:12:42 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:46336 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726171AbgBPOMl (ORCPT ); Sun, 16 Feb 2020 09:12:41 -0500 Received: from ip5f5bf7ec.dynamic.kabel-deutschland.de ([95.91.247.236] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1j3Kf0-0000yC-JA; Sun, 16 Feb 2020 14:12:38 +0000 Date: Sun, 16 Feb 2020 15:12:37 +0100 From: Christian Brauner To: Tycho Andersen Cc: linux-security-module@vger.kernel.org, Kees Cook , Jonathan Corbet , Alexey Dobriyan , linux-api@vger.kernel.org, containers@lists.linux-foundation.org, Jann Horn , linux-kernel@vger.kernel.org, smbarber@chromium.org, Seth Forshee , "Eric W. Biederman" , linux-fsdevel@vger.kernel.org, Alexander Viro Subject: Re: [PATCH v2 19/28] stat: handle fsid mappings Message-ID: <20200216141237.nk7yh7hdwpo5nmfx@wittgenstein> References: <20200214183554.1133805-1-christian.brauner@ubuntu.com> <20200214183554.1133805-20-christian.brauner@ubuntu.com> <20200214190314.GD22883@cisco> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200214190314.GD22883@cisco> Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: On Fri, Feb 14, 2020 at 12:03:14PM -0700, Tycho Andersen wrote: > On Fri, Feb 14, 2020 at 07:35:45PM +0100, Christian Brauner wrote: > > @@ -471,8 +484,13 @@ static long cp_new_stat64(struct kstat *stat, struct stat64 __user *statbuf) > > #endif > > tmp.st_mode = stat->mode; > > tmp.st_nlink = stat->nlink; > > - tmp.st_uid = from_kuid_munged(current_user_ns(), stat->uid); > > - tmp.st_gid = from_kgid_munged(current_user_ns(), stat->gid); > > + if (stat->userns_visible) { > > + tmp.st_uid, from_kuid_munged(current_user_ns(), stat->uid); > > + tmp.st_gid, from_kgid_munged(current_user_ns(), stat->gid); > > + } else { > > + tmp.st_uid, from_kfsuid_munged(current_user_ns(), stat->uid); > > + tmp.st_gid, from_kfsgid_munged(current_user_ns(), stat->gid); > > + } > > I suppose this should be = ? Good catch. I thought I had eliminated all those by doing automated conversion but apparently not. :) Christian