From: Casey Schaufler <casey@schaufler-ca.com>
To: Hongjian Dai <daihongjian@kylinsec.com.cn>
Cc: paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com,
linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org,
Casey Schaufler <casey@schaufler-ca.com>
Subject: Re: [PATCH v2] smackfs: fix IPv6 netlabel prefix mask for non-16-aligned lengths
Date: Tue, 1 Dec 2026 14:37:19 -0800 [thread overview]
Message-ID: <05442ec6-729f-44d2-9035-813102d01734@schaufler-ca.com> (raw)
In-Reply-To: <49DF0992E528A465+20261117021108.209924-1-daihongjian@kylinsec.com.cn>
On 11/16/2026 6:11 PM, Hongjian Dai wrote:
> smk_write_net6addr() builds the partial-word mask as (1 << m) - 1,
> which keeps the low m bits instead of the high m bits (e.g. /33
> yields 0x0001 instead of 0x8000), and stores it without htons()
> while the address words are in network byte order. Any prefix with
> mask % 16 != 0 is truncated to the wrong network and mislabeled.
>
> Take the high m bits and convert to network byte order, matching
> how newname words are stored with htons().
>
> Fixes: 21abb1ec414c ("Smack: IPv6 host labeling")
> Signed-off-by: Hongjian Dai <daihongjian@kylinsec.com.cn>
Applied to smack-next. Thank you.
> ---
> Link: https://lore.kernel.org/linux-security-module/A82C90B4956EE3A9+20260922144738.9594-1-daihongjian@kylinsec.com.cn/
> v2: Added missing Signed-off-by tag (as requested by Casey).
> ---
> security/smack/smackfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
> index a72bc7fabea9..6d680424a8c3 100644
> --- a/security/smack/smackfs.c
> +++ b/security/smack/smackfs.c
> @@ -1506,7 +1506,7 @@ static ssize_t smk_write_net6addr(struct file *file, const char __user *buf,
> fullmask.s6_addr16[i] = 0xffff;
> m -= 16;
> } else if (m > 0) {
> - fullmask.s6_addr16[i] = (1 << m) - 1;
> + fullmask.s6_addr16[i] = htons(0xffff << (16 - m));
> m = 0;
> } else
> fullmask.s6_addr16[i] = 0;
prev parent reply other threads:[~2026-12-01 22:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 2:11 Hongjian Dai
2026-12-01 22:37 ` Casey Schaufler [this message]
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=05442ec6-729f-44d2-9035-813102d01734@schaufler-ca.com \
--to=casey@schaufler-ca.com \
--cc=daihongjian@kylinsec.com.cn \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=serge@hallyn.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
all inboxes | Powered by JetHome®