Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp70920lqp; Sun, 9 Jun 2024 17:19:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW1sYXqPNQ3nlZFIEL3yeDeZ42YMZef5RLcUm/HjSiUwdjBlzsjrqpSk495snjiqb/IYMVrHUzicE7xLIUmV72gjzBR25AnwfEbsFQjJg== X-Google-Smtp-Source: AGHT+IF/zU2YbFhiI59CIPSUhPXbfY4RHFiZJEfTWV6pf0STP72LkbM5j/FQEliqN2nZEc2uXZVG X-Received: by 2002:a17:902:f688:b0:1f6:5013:7842 with SMTP id d9443c01a7336-1f6d02ddca4mr104965715ad.27.1717978760804; Sun, 09 Jun 2024 17:19:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717978760; cv=pass; d=google.com; s=arc-20160816; b=HoyVHwBxMK/6/+LY91bOtkmE3mdr+wAAO6HABkoUHrrQ1p/HOa8buUrfGk87iBvjew FZTz/V5FfgVDS4P9KvZVrmXib/tQZK3B3xpfQb5wqhZ+9XpuNjKJN5zSbJH2/jbMr7ah 9crRDalOxXNEwI4NKyCBCa2kKMv3EZuFhO3j33Nd+Bub23E4uaOVGdD82rT51Q97NhC7 athkKpfZCqKfgFnJi40jBYz0rK3qGCH6ruTaUBgv2N/UVVYT8LHcOay+2O81yZWhS93U CCUmCYeJ2x16fHHKR+k7Tnh/aiXlR/qEQyE3K0YylrUsvtD/Z6kJI+skib/MXwtiRwZJ 3YXw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=DaBC4lccKq90V2Qdlha3eJDRzM1Bcauqmp5mASHkKAs=; fh=CaI/qEsl105iMcr8EZa9FzKurDGU9gKhcIzCEY2MNKI=; b=W4DPIo7nLZcdX2M71pip6eJzU2SilW+y+FMnBsa+ooV3JpYTucgdIjXfNhoj7BJgn6 szEAx+D29q79q9Gx34CCNK5Kn/gm2u6hG2ruS4ya2NhT+plhy45Obrb2gk/f4DIJE4So CrlBkzlo8LI4BClT4vq1tCtMIzuftiHztLCt6MwLhzPQl9ui2bG6YHVSYbU2NQdpwcQG GJnrKtx5cboNd+yG/mqI8YgmnjVvPvERgDdr7yZKHEYiivtn1TzSVCWvgf9YCOBljuQB ZAIGvMbcq8eUjmKQW2u8YlkYeJmn7wSUaY7GUnBn+5PetbUepKJTAAjnrznGPdd+ZGyf B4Cw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=RBSp1Q0K; arc=pass (i=1 spf=pass spfdomain=paul-moore.com dkim=pass dkdomain=paul-moore.com dmarc=pass fromdomain=paul-moore.com); spf=pass (google.com: domain of linux-kernel+bounces-207566-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207566-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f6bd7d2d77si67969665ad.317.2024.06.09.17.19.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 17:19:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207566-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=RBSp1Q0K; arc=pass (i=1 spf=pass spfdomain=paul-moore.com dkim=pass dkdomain=paul-moore.com dmarc=pass fromdomain=paul-moore.com); spf=pass (google.com: domain of linux-kernel+bounces-207566-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207566-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com 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 9D0D1B20C82 for ; Mon, 10 Jun 2024 00:19:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF6D323B0; Mon, 10 Jun 2024 00:19:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="RBSp1Q0K" Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F1E917CD for ; Mon, 10 Jun 2024 00:19:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717978743; cv=none; b=DezNPQqTeBLA+RAUf9FAFPsx50GpTdcsR5ZGKfPwnhTIQBBUK69d+6GP8ktyWRI0Wr4trOTXEY18uO6XICrTIQJavniYq3EYr27okiXmQB4CC+HYJSJrRFGlhbqlzDqvv+YUoZMBBLIu5Gk+QYpgl1h3jRJLs+D+wAJyE92GYzg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717978743; c=relaxed/simple; bh=ouwqqZ0IrZq2p2VNSQskkMAORAvHn7/TuYsSh0/Nnes=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=lN4vMpAT0G2gTa16u6sqba5QS1v204gOLaL6SdwVOiyX5iALOLz7Q8idssX4mk1mbzvNmi7w8fqXYXNMlKXkrdYwQvHHB1Jdys9S/ZT2Tibx4J9ZLh01fqO7di2dC6ATyCSnHFuwQghz5Z2/F7QgfCEbexlTHKricFhCcYQtXvg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=RBSp1Q0K; arc=none smtp.client-ip=209.85.219.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Received: by mail-yb1-f172.google.com with SMTP id 3f1490d57ef6-dfb12c0b4ceso991918276.3 for ; Sun, 09 Jun 2024 17:19:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1717978740; x=1718583540; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=DaBC4lccKq90V2Qdlha3eJDRzM1Bcauqmp5mASHkKAs=; b=RBSp1Q0KZSkKXckwKm0NH9KWKK5B+2YY5YU4X/4nzvQWEKPM1v55ClNvnC7+Yny4jC Uc3bPfpFgjmC0zjs+fdvdjzoQDxGJuSlUEp8DCWfatyKzs6qil3gyCYvKQgcGElhOAzx P1C9KAk+0vHoMGuVp1BOPlydzgjvuEhRsAEsD7kHLRwdVoJzLXtU1kFGlexxszvYLhpV RW5PYCH3gr9itlXgflPMlGvcobNWzbGArbc2ztA8wDEv0N6mmfEjwRxGMV05SWDQkZ6/ hTer95s4MbetC8+D4CQnIjl1+EsjgEQb7pDoJCIMONxKk9D3QxuztjlH/INCSjT6GhE0 JqDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717978740; x=1718583540; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DaBC4lccKq90V2Qdlha3eJDRzM1Bcauqmp5mASHkKAs=; b=tr6GY6b90paEatIRak/vtvwn+lB85sHV+ettImo1tV1zmNKAnL8kLCR6n+9iFh/ZcS 8DDptP/FRMacKULDaHsGoF7ad8QnX0JeJtqSQT/jQY2XcEPvEyD2TNMmF/wRFqnkm4/K lNXU67hcen+1Nf9+tC3Y7wGdBX9CLWy1WJDtarwSZRVcqi70GiNDueOfmyGMvFlFlJZA NeypSE5sJgklQcVXeOlO+CdrNSLsKtW2dv2WrvyuB5I5S4GwwPOtfqtwBgcnJT4ZZOE/ pfMDnSQ4Zu29Zazkl6QJC6x8wAXVjdmfPBEHFKQkT9mffK82B1D30KXPMnnANYJNu+E4 faAw== X-Forwarded-Encrypted: i=1; AJvYcCWrHzjuUkYe5hE5nAB2Cp37Jdu4UtI0ujWEMOBGhReaqkIJ7JmaoLdv7iKME4YRmhl3T0bOcPerL1zjFBn/ExJ44itL+fLs2Z+Gg8/X X-Gm-Message-State: AOJu0YxfR/IWG6C3v9Gnl88JpwtrUUoQU2quJbnWHriTyHaIUrT4uIyx vdjDnB2zUqM5GmpEK6AN69oNmAWpNZ2cVatLv6Hoiit80epqxQWvT+fFcOPIrx8zpXJioejtCwQ zi2DIFN6HoWgHFOPgcj3Qu3GxgUb1WwwJQG99 X-Received: by 2002:a5b:2ce:0:b0:dfb:308f:911 with SMTP id 3f1490d57ef6-dfb308f0b87mr1143735276.60.1717978740109; Sun, 09 Jun 2024 17:19:00 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240609104355.442002-1-jcalmels@3xx0.net> <20240609104355.442002-5-jcalmels@3xx0.net> In-Reply-To: <20240609104355.442002-5-jcalmels@3xx0.net> From: Paul Moore Date: Sun, 9 Jun 2024 20:18:48 -0400 Message-ID: Subject: Re: [PATCH v2 4/4] bpf,lsm: Allow editing capabilities in BPF-LSM hooks To: Jonathan Calmels Cc: brauner@kernel.org, ebiederm@xmission.com, Jonathan Corbet , James Morris , "Serge E. Hallyn" , KP Singh , Matt Bobrowski , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , Stanislav Fomichev , Hao Luo , Jiri Olsa , Luis Chamberlain , Kees Cook , Joel Granados , John Johansen , David Howells , Jarkko Sakkinen , Stephen Smalley , Ondrej Mosnacek , Mykola Lysenko , Shuah Khan , containers@lists.linux.dev, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, linux-security-module@vger.kernel.org, bpf@vger.kernel.org, apparmor@lists.ubuntu.com, keyrings@vger.kernel.org, selinux@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Jun 9, 2024 at 6:40=E2=80=AFAM Jonathan Calmels = wrote: > > This patch allows modifying the various capabilities of the struct cred > in BPF-LSM hooks. More specifically, the userns_create hook called > prior to creating a new user namespace. > > With the introduction of userns capabilities, this effectively provides > a simple way for LSMs to control the capabilities granted to a user > namespace and all its descendants. > > Update the selftests accordingly by dropping CAP_SYS_ADMIN in > namespaces and checking the resulting task's bounding set. > > Signed-off-by: Jonathan Calmels > --- > include/linux/lsm_hook_defs.h | 2 +- > include/linux/security.h | 4 +- > kernel/bpf/bpf_lsm.c | 55 +++++++++++++++++++ > security/apparmor/lsm.c | 2 +- > security/security.c | 6 +- > security/selinux/hooks.c | 2 +- > .../selftests/bpf/prog_tests/deny_namespace.c | 12 ++-- > .../selftests/bpf/progs/test_deny_namespace.c | 7 ++- > 8 files changed, 76 insertions(+), 14 deletions(-) I'm not sure we want to go down the path of a LSM modifying the POSIX capabilities of a task, other than the capabilities/commoncap LSM. It sets a bad precedent and could further complicate issues around LSM ordering. -- paul-moore.com