From: sashiko-bot@kernel.org
Cc: linux-security-module@vger.kernel.org
Subject: Re: [PATCH] smackfs: reject out-of-range IPv4 octets in netlabel writes
Date: Mon, 21 Sep 2026 01:55:46 +0000 [thread overview]
Message-ID: <20260921015546.C351D1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <FFA41AC93858A96A+20260921014555.20351-1-daihongjian@kylinsec.com.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] smackfs: out-of-bounds IPv4 octet validation bypassed via integer wrap-around
--
commit 13135cde4c7fdf9b39cec7b05019b4e50745e1ad
Author: Hongjian Dai <daihongjian@kylinsec.com.cn>
smackfs: reject out-of-range IPv4 octets in netlabel writes
This commit attempts to fix a misconfiguration vulnerability in
smk_write_net4addr() where out-of-range IPv4 octets were silently wrapped by
sscanf with %hhd. It changes the sscanf format to %u and adds explicit
bounds checking before storing the address.
> diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
> index 6e62dcb36f74f..5d8bddffbabd3 100644
> --- a/security/smack/smackfs.c
> +++ b/security/smack/smackfs.c
[ ... ]
> @@ -1189,17 +1190,26 @@ static ssize_t smk_write_net4addr(struct file *file, const char __user *buf,
> goto free_data_out;
> }
>
> - rc = sscanf(data, "%hhd.%hhd.%hhd.%hhd/%u %s",
> - &host[0], &host[1], &host[2], &host[3], &masks, smack);
> + rc = sscanf(data, "%u.%u.%u.%u/%u %s",
> + &octet[0], &octet[1], &octet[2], &octet[3], &masks, smack);
> if (rc != 6) {
> - rc = sscanf(data, "%hhd.%hhd.%hhd.%hhd %s",
> - &host[0], &host[1], &host[2], &host[3], smack);
> + rc = sscanf(data, "%u.%u.%u.%u %s",
> + &octet[0], &octet[1], &octet[2], &octet[3], smack);
> if (rc != 5) {
> rc = -EINVAL;
> goto free_out;
> }
> masks = 32;
> }
> + if (octet[0] > 255 || octet[1] > 255 || octet[2] > 255 ||
> + octet[3] > 255) {
[Severity: Medium]
Does this still silently wrap if an input value is >= 2^32?
The kernel's sscanf implementation for %u parses into a 64-bit unsigned long
long and truncates it to a 32-bit unsigned int.
Input values like 4294967296 are silently truncated to values <= 255, which
would completely bypass this new validation check and reproduce the exact
silent-wrapping misconfiguration this patch intends to fix.
> + rc = -EINVAL;
> + goto free_out;
> + }
> + host[0] = octet[0];
> + host[1] = octet[1];
> + host[2] = octet[2];
> + host[3] = octet[3];
> if (masks > BEBITS) {
> rc = -EINVAL;
> goto free_out;
--
Sashiko AI review · https://sashiko.dev/#/patchset/FFA41AC93858A96A+20260921014555.20351-1-daihongjian@kylinsec.com.cn?part=1
prev parent reply other threads:[~2026-09-21 1:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 1:45 [PATCH] smackfs: reject out-of-range IPv4 octets in netlabel writes Hongjian Dai
2026-09-21 1:55 ` sashiko-bot [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=20260921015546.C351D1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.