From: Paul Moore <paul@paul-moore.com>
To: Zhan Xusheng <zhanxusheng1024@gmail.com>
Cc: Eric Paris <eparis@redhat.com>,
Ricardo Robaina <rrobaina@redhat.com>,
Richard Guy Briggs <rgb@redhat.com>,
audit@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Zhan Xusheng <zhanxusheng@xiaomi.com>
Subject: Re: [PATCH v2] audit: fix potential integer overflow in audit_log_n_string()
Date: Thu, 23 Jul 2026 13:43:39 -0400 [thread overview]
Message-ID: <d79fe8753ff88268bbd9bcd601cc4aa1@paul-moore.com> (raw)
In-Reply-To: <20260718050922.1980425-1-zhanxusheng@xiaomi.com>
On Jul 18, 2026 Zhan Xusheng <zhanxusheng1024@gmail.com> wrote:
>
> audit_log_n_string() computes new_len as "slen + 3" (enclosing quotes
> plus the NUL terminator) and stores it into an int, while slen is a
> size_t. For a sufficiently large slen the addition can overflow and/or
> the result be truncated when assigned to the int new_len, so the
> "new_len > avail" check can be bypassed and the subsequent
> memcpy(ptr, string, slen) can write past the skb tail.
>
> This is the same class of bug that was fixed for the hex sibling in
> commit 65dfde57d1e2 ("audit: fix potential integer overflow in
> audit_log_n_hex()"); both helpers are reached through
> audit_log_n_untrustedstring() with the same length source.
>
> Make new_len a size_t and use check_add_overflow() to catch the
> overflow, mirroring the audit_log_n_hex() fix. No functional change for
> the in-tree callers, which all pass bounded lengths.
>
> Fixes: 168b7173959f ("AUDIT: Clean up logging of untrusted strings")
> Cc: stable@vger.kernel.org
> Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
> ---
> v2:
> - drop the unnecessary (size_t) cast on the constant (Paul Moore)
> - emit "?" instead of "\"?\"" on overflow, matching
> audit_log_n_hex() (Paul Moore)
>
> kernel/audit.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
Merged into audit/stable-7.2 with the intent of sending this up to Linus
once it has gone through some testing. Thanks!
--
paul-moore.com
prev parent reply other threads:[~2026-07-23 17:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 2:46 [PATCH] audit: fix potential integer overflow in audit_log_n_string() Zhan Xusheng
2026-07-17 21:44 ` Paul Moore
2026-07-18 5:09 ` [PATCH v2] " Zhan Xusheng
2026-07-23 17:43 ` Paul Moore [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=d79fe8753ff88268bbd9bcd601cc4aa1@paul-moore.com \
--to=paul@paul-moore.com \
--cc=audit@vger.kernel.org \
--cc=eparis@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rgb@redhat.com \
--cc=rrobaina@redhat.com \
--cc=stable@vger.kernel.org \
--cc=zhanxusheng1024@gmail.com \
--cc=zhanxusheng@xiaomi.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