From: sashiko-bot@kernel.org
Cc: selinux@vger.kernel.org
Subject: Re: [PATCH v2 5/7] Smack: hooks for secctx_to_lsmprop and update_lsmprop
Date: Wed, 02 Sep 2026 22:17:16 +0000 [thread overview]
Message-ID: <20260902221717.272551F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260902220150.18586-6-casey@schaufler-ca.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] smack_secctx_to_lsmprop unconditionally returns success even when a label is unrecognized, setting prop->smack.skp to NULL which causes subsequent LSM hooks to crash.
--
commit f9e66992c2da2f752b05c3f6b558475dc2678c3b
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 ff115068c5c06..fcfadd5d99941 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
[ ... ]
> @@ -4909,6 +4909,37 @@ 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);
> +
> + return 0;
[Severity: Critical]
Will this return 0 (success) even when a label is unrecognized and
smk_find_entry() returns NULL?
If an unprivileged user with CAP_NET_ADMIN in a namespace configures an
invalid Smack label via Netfilter (e.g., xt_SECMARK or nft_meta), this
function will return success but leave prop->smack.skp as NULL.
Because it returned success, the networking code will consider the lsm_prop
valid. When a network packet hits an NFQUEUE target, the queue attempts to
retrieve the security context by calling security_lsmprop_to_secctx(), which
invokes smack_lsmprop_to_secctx() and blindly passes the NULL pointer to
smack_to_secctx():
security/smack/smack_lsm.c:smack_lsmprop_to_secctx() {
return smack_to_secctx(prop->smack.skp, cp);
}
This leads to an immediate kernel panic when the NULL pointer is dereferenced:
security/smack/smack_lsm.c:smack_to_secctx() {
int len = strlen(skp->smk_known);
...
}
Could this function be updated to return an error code such as -EINVAL when
the label is unrecognized, preventing the crash?
> +}
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260902220150.18586-1-casey@schaufler-ca.com?part=5
next prev parent reply other threads:[~2026-09-02 22:17 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260902220150.18586-1-casey.ref@schaufler-ca.com>
2026-09-02 22:01 ` [PATCH v2 0/7] Change skb secmarks to x-array indexes Casey Schaufler
2026-09-02 22:01 ` [PATCH v2 1/7] net, smack: Create a function to set secmarks Casey Schaufler
2026-09-02 22:13 ` sashiko-bot
2026-09-03 5:35 ` John Johansen
2026-09-02 22:01 ` [PATCH v2 2/7] LSM: Implement x array functions for secmarks Casey Schaufler
2026-09-02 22:21 ` sashiko-bot
2026-09-03 5:36 ` John Johansen
2026-09-02 22:01 ` [PATCH v2 3/7] LSM: Two hooks for manipulating struct lsm_prop Casey Schaufler
2026-09-02 22:16 ` sashiko-bot
2026-09-03 9:40 ` John Johansen
2026-09-02 22:01 ` [PATCH v2 4/7] SELinux: hooks for secctx_to_lsmprop and update_lsmprop Casey Schaufler
2026-09-02 22:10 ` sashiko-bot
2026-09-03 6:10 ` John Johansen
2026-09-02 22:01 ` [PATCH v2 5/7] Smack: " Casey Schaufler
2026-09-02 22:17 ` sashiko-bot [this message]
2026-09-03 6:15 ` John Johansen
2026-09-02 22:01 ` [PATCH v2 6/7] Apparmor: " Casey Schaufler
2026-09-02 22:16 ` sashiko-bot
2026-09-03 9:39 ` John Johansen
2026-09-02 22:01 ` [PATCH v2 7/7] net, lsm: Change skb secmarks to x-array indexes Casey Schaufler
2026-09-02 22:15 ` sashiko-bot
2026-09-03 7:31 ` John Johansen
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=20260902221717.272551F000E9@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.