From: sashiko-bot@kernel.org
Cc: selinux@vger.kernel.org
Subject: Re: [PATCH 5/7] Smack: hooks for secctx_to_lsmprop and update_lsmprop
Date: Fri, 14 Aug 2026 02:08:03 +0000 [thread overview]
Message-ID: <20260814020803.AA1861F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260813204854.19211-6-casey@schaufler-ca.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Out-of-bounds read in `smack_secctx_to_lsmprop` due to ignored `seclen` parameter.
- [High] NULL pointer dereference when an unknown security label is provided to `smack_secctx_to_lsmprop`.
- [High] RCU locking violation when calling `smk_find_entry()` from `smack_secctx_to_lsmprop`.
--
--- Patch [5]: [PATCH 5/7] Smack: hooks for secctx_to_lsmprop and update_lsmprop ---
commit dbfa723dc5394e90f883ff953a774973bbb1759e
Author: Casey Schaufler <casey@schaufler-ca.com>
Smack: hooks for secctx_to_lsmprop and update_lsmprop
Implement these hooks.
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index 3f9ae05039a28..cd9f5765979ff 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
[ ... ]
> @@ -4914,6 +4914,40 @@ static int smack_lsmprop_to_secctx(struct lsm_prop *prop,
> return smack_to_secctx(prop->smack.skp, cp);
> }
>
> +/**
> + * smack_secctx_to_lsmprop - add the smack label to an lsmprop
> + * @secdata: smack label
> + * @seclen: how long label is
> + * @prop: where to put the result
> + *
> + * Exists for audit and networking code.
> + */
> +static int smack_secctx_to_lsmprop(const char *secdata, u32 seclen,
> + struct lsm_prop *prop)
> +{
> + prop->smack.skp = smk_find_entry(secdata);
[Severity: High]
Does this code ignore the seclen parameter? If secdata is provided by
networking code or audit without null termination, passing it directly to
smk_find_entry() will cause an out-of-bounds read:
security/smack/smack_access.c:smk_find_entry() {
...
hash = full_name_hash(NULL, string, strlen(string));
...
}
Should this code respect seclen or ensure secdata is null-terminated before
the search?
[Severity: High]
Is it safe to call smk_find_entry() here without holding the RCU read lock?
Looking at smk_find_entry() in security/smack/smack_access.c, it traverses the
hash list using RCU:
hlist_for_each_entry_rcu(skp, head, smk_hashed) {
...
}
Without an rcu_read_lock() wrapping this call, could this trigger a lockdep
warning or read malformed pointers during a concurrent insertion?
> +
> + return 0;
[Severity: High]
If smk_find_entry() fails to find a matching label, it returns NULL. By
returning 0 (success) here, we leave prop->smack.skp as NULL.
When this property is later passed to smack_lsmprop_to_secctx(), it will
delegate to smack_to_secctx():
security/smack/smack_lsm.c:smack_to_secctx() {
int len = strlen(skp->smk_known);
...
}
Will this cause a deterministic NULL pointer dereference? Should this
function return an error like -EINVAL when the label is not found?
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260813204854.19211-1-casey@schaufler-ca.com?part=5
next prev parent reply other threads:[~2026-08-14 2:08 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260813204854.19211-1-casey.ref@schaufler-ca.com>
2026-08-13 20:48 ` [PATCH 0/7] Change skb secmarks to x-array indexes Casey Schaufler
2026-08-13 20:48 ` [PATCH 1/7] net, smack: Create a function to set secmarks Casey Schaufler
2026-08-14 1:06 ` sashiko-bot
2026-08-13 20:48 ` [PATCH 2/7] LSM: Implement x array functions for secmarks Casey Schaufler
2026-08-14 1:26 ` sashiko-bot
2026-08-13 20:48 ` [PATCH 3/7] LSM: Two hooks for manipulating struct lsm_prop Casey Schaufler
2026-08-14 1:38 ` sashiko-bot
2026-08-13 20:48 ` [PATCH 4/7] SELinux: hooks for secctx_to_lsmprop and update_lsmprop Casey Schaufler
2026-08-14 1:55 ` sashiko-bot
2026-08-13 20:48 ` [PATCH 5/7] Smack: " Casey Schaufler
2026-08-14 2:08 ` sashiko-bot [this message]
2026-08-13 20:48 ` [PATCH 6/7] Apparmor: " Casey Schaufler
2026-08-14 2:23 ` sashiko-bot
2026-08-13 20:48 ` [PATCH 7/7] net, lsm: Change skb secmarks to x-array indexes Casey Schaufler
2026-08-14 2:39 ` sashiko-bot
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=20260814020803.AA1861F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=selinux@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.