Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp407188rdb; Thu, 22 Feb 2024 07:25:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXKaPzkup5iLt65jBAN3avbhoVe0XaLPGZlxMLzx1wyQhIGiiTWe7V7z1yY1JjBxNsYq0a+3VuPDIfBHx69/O194zeZFWPIDUol3/txGA== X-Google-Smtp-Source: AGHT+IFcHev95MYNhrD6uVGdLEp1lsFvgS+5plN0KVKT5f+VgGdaidKrQDStZQuYYqGpj337cBWh X-Received: by 2002:a17:902:ecc7:b0:1dc:15db:bcca with SMTP id a7-20020a170902ecc700b001dc15dbbccamr10001228plh.55.1708615537543; Thu, 22 Feb 2024 07:25:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708615537; cv=pass; d=google.com; s=arc-20160816; b=p9Hr0GlNBIXJpK6xt7hlMBgsUefEVJxdtkskDAlclQwUq0jBc0fZ2UOfgo4G8pT04/ wL+1QqSiwagk5U9Sz0hyF1OS2QGpTqQh3O0Vbk6oY+YXxJqB49emlGq68e//7TcYuhf2 wGP5jLYDAqb4g4TEIRWSg8GK1xCcogy52xpqAPQoUqULFqHvNldVIL4zjMXxhPMYnrht c9YVx/bRhOx9dTdr4NdrNlaCZywpKFbVY9mwv6Gis1rn5uCCsiLEq2/Zt7An9fXygNGg vJVC1MyICgYKu98ElVUkWcTARAKsEXJdhMWAHymdlT4vsfP6OA6gN3GFcRHvYXFDCjzv yO4g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=zXVDHLIqCcALU/u4m7fOPzIOYBTF6LE+eh+pPWEVz2Y=; fh=8DYu7hEZnfOKz8raIQkeMuIl5TIwtVW8vrBSs0XLekQ=; b=DpqQ22S87OcwYrRztTOkuxQYu8y05KOsbq2U7dvkKBa24PPO+os1TNPuvBekMesno+ VaQtrgdKjHR+NRDxHR6uD/KwoWFgjqaTZcsKHfdFjDDLVfOiZBmlTxLQ9AKT3fykudqR k08Mw/Gt5nzQxVEh/cRjuFBFqXfXEaIBBx/YFAkC806zkQdrrbGcEO37mW+ySH/ZgahV V9sq1/qRIG6EtwFHNL4FdOpCQA5J5vkKghfi0rMzVOY3/fS9ZEFGHWpobCJ2tJZ3BObA j1K/8ZerksrZkVzYusaw2wErAUQVUY7O2UUKkXwzS5lZgWSa8qELILLppM75vFGKn0zK OlvQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Wh2e4QBZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-76767-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76767-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q14-20020a17090311ce00b001d8edfe3a27si10546278plh.163.2024.02.22.07.25.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 07:25:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76767-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Wh2e4QBZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-76767-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76767-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 282C3B266A3 for ; Thu, 22 Feb 2024 15:23:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4162B14C5BD; Thu, 22 Feb 2024 15:22:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Wh2e4QBZ" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EA691353E2; Thu, 22 Feb 2024 15:22:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708615373; cv=none; b=jkN4VUzrIt1zhNEuN6aFoCo3wLd8w2sP+UTgx8MrS7yFHIGKNHTg7DbDCCWcKx0VmXPhF1kPA82T0rx+ctxvpHGW26pfj0nRrVtuWeJmm1Toy1iZeKwh3WCVs+562AXcnblQgO1WZ1OaC91n9mtB/tQBJWbBNaxQ/KqEofxdWkw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708615373; c=relaxed/simple; bh=nIRV4TxaPa6vXCVCxIMnFBsUIz9LyGcVVI0m7g2TYzo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=t4mmP1YkLnjtYHML+/qe9bmNA2RISoEjxzxTJ+sft3/ySA72n5nXTZ0i8ry041jc81Gxp2Rf1w0+X/wSC/y+mlxBqhI1KNxNKOyRVbDN/Mo5idhEA+pghB+7c9jaj3PXAml9AXXJzDSsZEcqGEkX1uiy/WseicWsxoXESLxgYj8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Wh2e4QBZ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73EC1C433F1; Thu, 22 Feb 2024 15:22:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708615372; bh=nIRV4TxaPa6vXCVCxIMnFBsUIz9LyGcVVI0m7g2TYzo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Wh2e4QBZn3IKMQYquvwDC4G6Wa8GTvdSdj+VkXWMspmApkYgGrH1IyNao+davZ9+N ph8/Dd0MxAckccCoxqRklZd4f9Gz32tTkspW1XZRNfBJEDdXdlKyZSvguG5P7DZNYE EYl53YqMTdXoVOhGJ4txQFTCQkwmx/zbFQAUZkWMarulGNDo7JqC0/Uw1KnarHwJco Kl7oSE/lQe4bqaa5oJMI6SfNazuEH9BGmBMNT4DeC86K7ONswklCHrq8nHhvlhhYuv e2F0Bputl9nA/cfmX957EaLzp9x7nWnpItnBESthxAszfsN0yV88BByS6giewzIbGR TR/hyUk/BCbHg== Date: Thu, 22 Feb 2024 16:22:44 +0100 From: Christian Brauner To: "Seth Forshee (DigitalOcean)" Cc: Serge Hallyn , Paul Moore , Eric Paris , James Morris , Alexander Viro , Jan Kara , Stephen Smalley , Ondrej Mosnacek , Casey Schaufler , Mimi Zohar , Roberto Sassu , Dmitry Kasatkin , Eric Snowberg , "Matthew Wilcox (Oracle)" , Jonathan Corbet , Miklos Szeredi , Amir Goldstein , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org, audit@vger.kernel.org, selinux@vger.kernel.org, linux-integrity@vger.kernel.org, linux-doc@vger.kernel.org, linux-unionfs@vger.kernel.org Subject: Re: [PATCH v2 07/25] capability: provide a helper for converting vfs_caps to xattr for userspace Message-ID: <20240222-amortisieren-geblendet-6e977e2d572c@brauner> References: <20240221-idmap-fscap-refactor-v2-0-3039364623bd@kernel.org> <20240221-idmap-fscap-refactor-v2-7-3039364623bd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240221-idmap-fscap-refactor-v2-7-3039364623bd@kernel.org> On Wed, Feb 21, 2024 at 03:24:38PM -0600, Seth Forshee (DigitalOcean) wrote: > cap_inode_getsecurity() implements a handful of policies for capability > xattrs read by userspace: > > - It returns EINVAL if the on-disk capability is in v1 format. > > - It masks off all bits in magic_etc except for the version and > VFS_CAP_FLAGS_EFFECTIVE. > > - v3 capabilities are converted to v2 format if the rootid returned to > userspace would be 0 or if the rootid corresponds to root in an > ancestor user namespace. > > - It returns EOVERFLOW for a v3 capability whose rootid does not map to > a valid id in current_user_ns() or to root in an ancestor namespace. > > These policies must be maintained when converting vfs_caps to an xattr > for userspace. Provide a vfs_caps_to_user_xattr() helper which will > enforce these policies. > > Signed-off-by: Seth Forshee (DigitalOcean) > --- Looks good, Reviewed-by: Christian Brauner