From: Paul Moore <paul@paul-moore.com>
To: Casey Schaufler <casey@schaufler-ca.com>,
casey@schaufler-ca.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,
linux-integrity@vger.kernel.org, netdev@vger.kernel.org,
audit@vger.kernel.org, netfilter-devel@vger.kernel.org,
linux-nfs@vger.kernel.org, Todd Kjos <tkjos@google.com>
Subject: Re: [PATCH v2 1/6] LSM: Ensure the correct LSM context releaser
Date: Mon, 21 Oct 2024 19:39:48 -0400 [thread overview]
Message-ID: <dad74779768e7c00d2a3c9bf8c60045d@paul-moore.com> (raw)
In-Reply-To: <20241014151450.73674-2-casey@schaufler-ca.com>
On Oct 14, 2024 Casey Schaufler <casey@schaufler-ca.com> wrote:
>
> Add a new lsm_context data structure to hold all the information about a
> "security context", including the string, its size and which LSM allocated
> the string. The allocation information is necessary because LSMs have
> different policies regarding the lifecycle of these strings. SELinux
> allocates and destroys them on each use, whereas Smack provides a pointer
> to an entry in a list that never goes away.
>
> Update security_release_secctx() to use the lsm_context instead of a
> (char *, len) pair. Change its callers to do likewise. The LSMs
> supporting this hook have had comments added to remind the developer
> that there is more work to be done.
>
> The BPF security module provides all LSM hooks. While there has yet to
> be a known instance of a BPF configuration that uses security contexts,
> the possibility is real. In the existing implementation there is
> potential for multiple frees in that case.
>
> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
> Cc: linux-integrity@vger.kernel.org
> Cc: netdev@vger.kernel.org
> Cc: audit@vger.kernel.org
> Cc: netfilter-devel@vger.kernel.org
> To: Pablo Neira Ayuso <pablo@netfilter.org>
> Cc: linux-nfs@vger.kernel.org
> Cc: Todd Kjos <tkjos@google.com>
> Reviewed-by: Serge Hallyn <sergeh@kernel.org>
> ---
> drivers/android/binder.c | 24 ++++++-------
> fs/ceph/xattr.c | 6 +++-
> fs/nfs/nfs4proc.c | 8 +++--
> fs/nfsd/nfs4xdr.c | 8 +++--
> include/linux/lsm_hook_defs.h | 2 +-
> include/linux/security.h | 35 +++++++++++++++++--
> include/net/scm.h | 11 +++---
> kernel/audit.c | 30 ++++++++---------
> kernel/auditsc.c | 23 +++++++------
> net/ipv4/ip_sockglue.c | 10 +++---
> net/netfilter/nf_conntrack_netlink.c | 10 +++---
> net/netfilter/nf_conntrack_standalone.c | 9 +++--
> net/netfilter/nfnetlink_queue.c | 13 ++++---
> net/netlabel/netlabel_unlabeled.c | 45 +++++++++++--------------
> net/netlabel/netlabel_user.c | 11 +++---
> security/apparmor/include/secid.h | 2 +-
> security/apparmor/secid.c | 11 ++++--
> security/security.c | 8 ++---
> security/selinux/hooks.c | 11 ++++--
> 19 files changed, 167 insertions(+), 110 deletions(-)
...
> diff --git a/net/netlabel/netlabel_unlabeled.c b/net/netlabel/netlabel_unlabeled.c
> index 1bc2d0890a9f..8303bbcfc543 100644
> --- a/net/netlabel/netlabel_unlabeled.c
> +++ b/net/netlabel/netlabel_unlabeled.c
> @@ -1127,14 +1122,14 @@ static int netlbl_unlabel_staticlist_gen(u32 cmd,
> secid = addr6->secid;
> }
>
> - ret_val = security_secid_to_secctx(secid, &secctx, &secctx_len);
> + ret_val = security_secid_to_secctx(secid, &ctx.context, &ctx.len);
> if (ret_val != 0)
> goto list_cb_failure;
> ret_val = nla_put(cb_arg->skb,
> NLBL_UNLABEL_A_SECCTX,
> - secctx_len,
> - secctx);
> - security_release_secctx(secctx, secctx_len);
> + ctx.len,
> + ctx.context);
Nitpicky alignment issue; please keep the arguments aligned as they
are currently.
> + security_release_secctx(&ctx);
> if (ret_val != 0)
> goto list_cb_failure;
>
--
paul-moore.com
next prev parent reply other threads:[~2024-10-21 23:39 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20241014151450.73674-1-casey.ref@schaufler-ca.com>
2024-10-14 15:14 ` [PATCH v2 0/6] LSM: Replace secctx/len pairs with lsm_context Casey Schaufler
2024-10-14 15:14 ` [PATCH v2 1/6] LSM: Ensure the correct LSM context releaser Casey Schaufler
2024-10-15 3:40 ` sergeh
2024-10-21 23:39 ` Paul Moore [this message]
2024-10-21 23:58 ` Casey Schaufler
2024-10-22 16:25 ` Paul Moore
2024-10-14 15:14 ` [PATCH v2 2/6] LSM: Replace context+len with lsm_context Casey Schaufler
2024-10-14 15:14 ` [PATCH v2 3/6] LSM: Use lsm_context in security_inode_getsecctx Casey Schaufler
2024-10-14 15:14 ` [PATCH v2 4/6] LSM: lsm_context in security_dentry_init_security Casey Schaufler
2024-10-21 23:39 ` Paul Moore
2024-10-22 0:00 ` Casey Schaufler
2024-10-22 16:35 ` Paul Moore
2024-10-22 16:46 ` Casey Schaufler
2024-10-14 15:14 ` [PATCH v2 5/6] LSM: secctx provider check on release Casey Schaufler
2024-10-21 23:39 ` Paul Moore
2024-10-22 0:05 ` Casey Schaufler
2024-10-22 16:28 ` Paul Moore
2024-10-14 15:14 ` [PATCH v2 6/6] LSM: Use lsm_context in security_inode_notifysecctx Casey Schaufler
2024-10-14 21:29 ` [PATCH v2 0/6] LSM: Replace secctx/len pairs with lsm_context Serge E. Hallyn
2024-10-14 21:35 ` Serge E. Hallyn
2024-10-14 21:54 ` Casey Schaufler
2024-10-14 21:47 ` Casey Schaufler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dad74779768e7c00d2a3c9bf8c60045d@paul-moore.com \
--to=paul@paul-moore.com \
--cc=audit@vger.kernel.org \
--cc=casey@schaufler-ca.com \
--cc=jmorris@namei.org \
--cc=john.johansen@canonical.com \
--cc=keescook@chromium.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mic@digikod.net \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=selinux@vger.kernel.org \
--cc=serge@hallyn.com \
--cc=stephen.smalley.work@gmail.com \
--cc=tkjos@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).