From patchwork Wed Oct 23 21:21:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Casey Schaufler X-Patchwork-Id: 13847968 Received: from sonic313-22.consmr.mail.bf2.yahoo.com (sonic313-22.consmr.mail.bf2.yahoo.com [74.6.133.196]) (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 4EF2015B0EE for ; Wed, 23 Oct 2024 21:22:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.6.133.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729718534; cv=none; b=gtJlwEBmFmFpadHMEspDwT96rtQI8gXrp0FMurlA9JuVzMjaAJ5y8MbvGdwQhYh7h/83T40Bhzdh2wWN4uhDPVKy/2DfBJ6jXgv6bN/WWXHmF79iXaAbAHdAntdBzz3qg6bGmH2IrLC/ZX2Kcvio703IcOXM9MxesZJTk14VM1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729718534; c=relaxed/simple; bh=6VSn9m0+4gEQ/QemkSdtlH1FACIinNvkgPUOAlJPnQk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:References; b=pamzq8s3C5RI2GJQXnRs9ehtxnr9L3tGEB53cyzDRdnrFh5oOMhFJ5CxX/olOdU1kmG2PczjNSALsGPUQe7A15jLhc9LpLdXB9pnw3vGrF37Z+f55DP6FHTjI26pLbJiYsfUXMSN31sMTjiXxkuP0jyKGaYI3o84itxFvDhyWeA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=schaufler-ca.com; spf=none smtp.mailfrom=schaufler-ca.com; dkim=pass (2048-bit key) header.d=yahoo.com header.i=@yahoo.com header.b=I0UqB5YY; arc=none smtp.client-ip=74.6.133.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=schaufler-ca.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=schaufler-ca.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=yahoo.com header.i=@yahoo.com header.b="I0UqB5YY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1729718524; bh=3qg/Mtih7gPvp6NyFPLR4Rs2mLIKzdNL25OcNztnx2I=; h=From:To:Cc:Subject:Date:References:From:Subject:Reply-To; b=I0UqB5YYeXK8/lVjDZk69SCVbmlZB5cUQYsfsdK4bXuZiT9vaqC7kxJ/j2GF4YeGwKXjQb7KaD+FlmEZi/TTM5xNkx2kOe5lKCI/EKgeWYgQuJx9a4kG8u13NO6QxVxmtefJ76bLeppDms0Vb/Q66k2rtC5N5XmdV+iVgbbAX8ONYxDJGq02rB6O+Oek6V8iinLqoDIlyz9uIW2I0r4l6GmtgLiP3p0hDUHqsfOxxNFyUhIyHUJb8qoEGfYFrr1q6DElq72vEBWm7LMoFO+atFs6idNKmipsMuaEYjd2jefti3YK/oDXxjI9JFO0mjl4H3nmlW+JcdeDNWdCz2qaeQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1729718524; bh=DpOqfmqrutMNJNlWP4j9QWtg9YOcj8qMzHXGeJCw7DH=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=PKtT93bjVAeE6Ed/D/RoiGMOhgqeb5feFrQwfbquv+DmAEt2WTyex0QSK7ViAOxSpO+5+xg1FfSuFy7+o0/FARC1uVVcXyIYXmzMlZK0dhBfwN7BNjMq1apaRNf5ow368i4l9kWUlS0OmSVWYQ7XNj9t9Eq6b2RBixuND4et6eoGs+iL4nhX6SUfW7gKBEFMYygoULu0xHSbFr4++aUnntscDy4jDXx+8LYDN+6sxuYCIGC7EsoGAOPq1aCCrkCU998K6fYJ3pm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EclWlXz0c0t3zqEqFZdoojOXJ8ImR57NBYPdmkkAIusnNpnDcYa0aC0SqX6 dspLkHMEMQkZi_Fkmu0sBWITF4sc2J6FXoY5JcJqF0JR6MpIWg2CdzBEZBxZcuuSE3nsxkaF_2uE 4P2AW9xFMPaFG.epxYWXUN84QGxgZSVbM2.qmF5xV89YPG7pTtyMHlKb5HjyY5CPoD1.fUrX8ORP IsXHSxAahLctdoWPNwTM7YOTRamYvDwUCZFCii4xVgdFjfSuBBzAPjxd_YKjB5ZLvCi74p0.xsBH mQPi2J6r.fGfV.3DQxOnd1A-- X-Sonic-MF: X-Sonic-ID: ef4f947b-0e71-4ba0-a253-5c2b5d6757af Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.bf2.yahoo.com with HTTP; Wed, 23 Oct 2024 21:22:04 +0000 Received: by hermes--production-gq1-5dd4b47f46-5xsmt (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 8a7972f72a0226c80fd86fd6bd5371c9; Wed, 23 Oct 2024 21:22:01 +0000 (UTC) From: Casey Schaufler To: casey@schaufler-ca.com, paul@paul-moore.com, linux-security-module@vger.kernel.org Cc: jmorris@namei.org, serge@hallyn.com, keescook@chromium.org, john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp, stephen.smalley.work@gmail.com, linux-kernel@vger.kernel.org, selinux@vger.kernel.org, mic@digikod.net Subject: [PATCH v3 0/5] LSM: Replace secctx/len pairs with lsm_context Date: Wed, 23 Oct 2024 14:21:53 -0700 Message-ID: <20241023212158.18718-1-casey@schaufler-ca.com> X-Mailer: git-send-email 2.46.0 Precedence: bulk X-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20241023212158.18718-1-casey.ref@schaufler-ca.com> LSM: Replace secctx/len pairs with lsm_context Several of the Linux Security Module (LSM) interfaces use a pair of pointers for transmitting security context data and data length. The data passed is refered to as a security context. While all existing modules provide nul terminated strings, there is no requirement that they to so. Hence, the length is necessary. Security contexts are provided by a number of interfaces. The interface security_release_secctx() is used when the caller is finished with the data. Each of the security modules that provide security contexts manages them differently. This was safe in the past, because only one security module that provides security contexts is allowed to be active. To allow multiple active modules that use security contexts it is necessary to identify which security module created a security context. Adding a third pointer to the interfaces for the LSM identification is not appealing. A new structure, lsm_context, is created for use in these interfaces. It includes three members: the data pointer, the data length and the LSM ID of its creator. The interfaces that create contexts and security_release_secctx() now use a pointer to an lsm_context instead of a pointer pair. The changes are mostly mechanical, and some scaffolding is used within the patch set to allow for smaller individual patches. This patch set depends on the patch set LSM: Move away from secids: https://github.com/cschaufler/lsm-stacking.git#lsmprop-6.12-rc1-v4 https://github.com/cschaufler/lsm-stacking.git#context-6.12-rc1-v3 Revisons: v3: Don't change NFS data storage format Retain argument alignments Set released context pointers to NULL v2: Rebase for static calls in LSM infrastructure Casey Schaufler (5): LSM: Ensure the correct LSM context releaser LSM: Replace context+len with lsm_context LSM: Use lsm_context in security_inode_getsecctx LSM: lsm_context in security_dentry_init_security LSM: secctx provider check on release drivers/android/binder.c | 25 +++++----- fs/ceph/super.h | 3 +- fs/ceph/xattr.c | 12 ++--- fs/fuse/dir.c | 35 +++++++------- fs/nfs/nfs4proc.c | 22 ++++++--- fs/nfsd/nfs4xdr.c | 22 ++++----- include/linux/lsm_hook_defs.h | 13 +++-- include/linux/security.h | 37 ++++++++++----- include/net/scm.h | 12 ++--- kernel/audit.c | 33 +++++++------ kernel/auditsc.c | 27 +++++------ net/ipv4/ip_sockglue.c | 12 ++--- net/netfilter/nf_conntrack_netlink.c | 16 +++---- net/netfilter/nf_conntrack_standalone.c | 11 ++--- net/netfilter/nfnetlink_queue.c | 22 ++++----- net/netlabel/netlabel_unlabeled.c | 44 +++++++---------- net/netlabel/netlabel_user.c | 10 ++-- security/apparmor/include/secid.h | 7 ++- security/apparmor/secid.c | 34 +++++++------ security/security.c | 63 ++++++++++++------------- security/selinux/hooks.c | 50 ++++++++++++++------ security/smack/smack_lsm.c | 49 +++++++++++-------- 22 files changed, 293 insertions(+), 266 deletions(-)