Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3991378pxb; Tue, 26 Jan 2021 09:33:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJ4e0mDPEVWvOqlxKvVw7JVFj1lAs6apvHjYLozSiDmRz5n26P2pXCPiPEO/hAT/TlwJBw X-Received: by 2002:a17:906:1116:: with SMTP id h22mr4207837eja.279.1611682402238; Tue, 26 Jan 2021 09:33:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611682402; cv=none; d=google.com; s=arc-20160816; b=qvaRovBDOsh2ithZmG7w4P8XEem4FGc4/GgMr4qmXRnphJeO/WOfXa4ToDBk9/eK0Z pUaoQV8vRObsu1HI5SU+zF1uFu53rYDDVHuDm06en51dsSsps9vvdn3AzFu+t3rr0/HN iQVJNEG/xbJh3QI5cw+jfzrUjnbf5VyK/HBuARZC3rpaC9vb6SvfBPpihHQWhsSbAD7/ lRTt1/jqybqVTcZ+pOsKdYqwKZ4B9f1vV1zyMxlMozkEVJY+gbcsR6oicLjyaDsX7k2U zfD9dwGohJpTB2VGIhnBTmb0n0Fi/93XKzH0Vp+Ii3LAbKXtEfj40KUDUpO4rK1nlThk o1Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=mKBAIHjLBv1uPqHgRWoGEuszBqIj+l3P9UDHtFckEn4=; b=KgycTlLml2ZeBwJaQAO0bUMvzEde9zOCBZKEqOlA2OOyWeq+gTWbBiCszPYiugse99 qRh5sHeGF5hAwu1hK45dKuq1hAzLBDHgdmA7mE2zSzOl6YhUfjuFlrOC3NUWwj/IrPqj oGvbfebkEBfj6eO0oo3r/2UevNk4cPJ8DCVGwL7qCch58TC4Det8J7UAuLa3LTfwfacx /ctVOJd0/dZjdL1PDYzmZwgUDkgVItXkGBlk6bLM4Rkl6u55Ux/PZnIDvv1gQRrI0b7N bqQr5ZyuCWw7Q1BmZO4WJvKkVALYMFedXN0TOGx5q+y2Jjh6Xf2/Ss58CA9KF3FzIwqW Iefg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LKaNWm1s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x7si8262883edq.562.2021.01.26.09.32.56; Tue, 26 Jan 2021 09:33:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LKaNWm1s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730357AbhAZGVf (ORCPT + 99 others); Tue, 26 Jan 2021 01:21:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:60256 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728822AbhAYN2A (ORCPT ); Mon, 25 Jan 2021 08:28:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611581153; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mKBAIHjLBv1uPqHgRWoGEuszBqIj+l3P9UDHtFckEn4=; b=LKaNWm1sI+LWt7z9lnCSfTd/bj4Qw0Z//IRwfImml33CKbSFOphOLOeTpqyrfdqjUGunav 66yvJHfBWJTkwz7cf3VVpbH/WWpm4JAp9aGe5GELrzrQXffI3LUct0NR8+bgDpfEFY5EcV 8/CYEq9Nd5u0ROrfA7ZoMnIreBqeaEk= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-542-uHrjmWgqNYqPUouv4Ebhkw-1; Mon, 25 Jan 2021 08:25:49 -0500 X-MC-Unique: uHrjmWgqNYqPUouv4Ebhkw-1 Received: by mail-qk1-f197.google.com with SMTP id s66so9843456qkh.10 for ; Mon, 25 Jan 2021 05:25:49 -0800 (PST) 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=mKBAIHjLBv1uPqHgRWoGEuszBqIj+l3P9UDHtFckEn4=; b=oUNU5M94Hyt2NEtRYqfiYb9lywSN2DSCsmCpF+43I4EZjBgVl23FiIiaysTzQUCRHb HSgCEqzAH+EJFx8Sb1fJJWOQ6Z89rr512E6NatWWfQ4Q1tjoFTaG+Jn0jTce+7sWz5H2 3J2nLpfm2KwcPN8byaOCseZqyOV/koIRWWZ45ZF9snLr3xVjWRzG4+x4WQkJd/1buWOR HzWvDWs0MuiYIg4wYjv7yrnW1ywWZJEQfdPSAclSgnjlsf8ensy0qT6kEwwz79EXsxhJ ciS1pQ5vV/W5cVxj6czeEHHtZJ1O74D0jt5FYjhn7sQ8ILwIaZbBSRY4uF/H3VmBzVGj pduA== X-Gm-Message-State: AOAM533JxMIXoqHlxqzvmqIR1aLChzamkaesYfEvhPun+7UeFfOwxqWG tB5VJV1MkWs+FUyq4Eb4zjJLj2ap+5eFGGYlW893/z8iqliR+ftrz8aZqcSAV7NCVJ8vY+6ec4o SvG9VF5mgOEFX/YkKyiDwe8S3WITlCxeLPsPuknlU X-Received: by 2002:a37:788:: with SMTP id 130mr656851qkh.390.1611581149429; Mon, 25 Jan 2021 05:25:49 -0800 (PST) X-Received: by 2002:a37:788:: with SMTP id 130mr656827qkh.390.1611581149237; Mon, 25 Jan 2021 05:25:49 -0800 (PST) MIME-Version: 1.0 References: <20210119162204.2081137-1-mszeredi@redhat.com> <20210119162204.2081137-2-mszeredi@redhat.com> <20210122183141.GB81247@sequoia> In-Reply-To: <20210122183141.GB81247@sequoia> From: Miklos Szeredi Date: Mon, 25 Jan 2021 14:25:38 +0100 Message-ID: Subject: Re: [PATCH 1/2] ecryptfs: fix uid translation for setxattr on security.capability To: Tyler Hicks Cc: "Eric W . Biederman" , linux-fsdevel , overlayfs , linux-security-module@vger.kernel.org, lkml , "Serge E . Hallyn" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 22, 2021 at 7:31 PM Tyler Hicks wrote: > > On 2021-01-19 17:22:03, Miklos Szeredi wrote: > > Prior to commit 7c03e2cda4a5 ("vfs: move cap_convert_nscap() call into > > vfs_setxattr()") the translation of nscap->rootid did not take stacked > > filesystems (overlayfs and ecryptfs) into account. > > > > That patch fixed the overlay case, but made the ecryptfs case worse. > > Thanks for sending a fix! > > I know that you don't have an eCryptfs setup to test with but I'm at a > loss about how to test this from the userns/fscaps side of things. Do > you have a sequence of unshare/setcap/getcap commands that I can run on > a file inside of an eCryptfs mount to verify that the bug exists after > 7c03e2cda4a5 and then again to verify that this patch fixes the bug? You need two terminals: $ = # = root $ unshare -Um $ echo $$ # echo "0 1000 1" > uid_map # cp uid_map gid_map # echo 1000 2000 1 >> uid_map # echo 2000 3000 1 >> uid_map # cat uid_map > /proc//uid_map # cat gid_map > /proc//gid_map $ mkdir ~/tmp ~/mnt $ mount -t tmpfs tmpfs ~/tmp $ pwd /home/ # nsenter -t -m # [setup ecryptfs on /home//mnt using /home//tmp] $ cd ~/mnt $ touch test $ /sbin/setcap -n 1000 cap_dac_override+eip test $ /sbin/getcap -n test test = cap_dac_override+eip [rootid=1000] Without the patch, I'm thinking that it will do a double translate and end up with rootid=2000 in the user namespace, but I might well have messed it up... Let me know how this goes. Thanks, Miklos