From: Andrew Morton <akpm@linux-foundation.org>
To: Oleg Deomi <oleg.deomi@gmail.com>
Cc: Balbir Singh <bsingharora@gmail.com>, linux-kernel@vger.kernel.org
Subject: Re: [BUG] taskstats: REGISTER_CPUMASK silently truncates the last byte of the cpumask string
Date: Tue, 21 Jul 2026 16:38:42 -0700 [thread overview]
Message-ID: <20260721163842.f08e18db987a749251cfa367@linux-foundation.org> (raw)
In-Reply-To: <CAByWkfZ6b1=3H9pwkz-dDQOs9cZaF-HYQ6b9Yb0=Hq2r1Vv_Pw@mail.gmail.com>
On Tue, 21 Jul 2026 15:52:33 +0300 Oleg Deomi <oleg.deomi@gmail.com> wrote:
> TASKSTATS REGISTER_CPUMASK silently drops the last byte of the cpumask
> string it's given, due to a destination-buffer-sizing bug in
> kernel/taskstats.c's parse(). A request for "0-31" is silently parsed as
> "0-3" instead — the call still succeeds (ACK, no error), so the caller
> has no way to detect that most of the CPUs it asked to cover were never
> actually registered.
Thanks, I queued this fix:
From: Andrew Morton <akpm@linux-foundation.org>
Subject: kernel/taskstats.c:parse(): fix buffer allocation size
Date: Tue Jul 21 04:30:41 PM PDT 2026
parse() is failing to allow for the nla_strscpy()'s null termination of
the cpumask string. This can result in the cpumask string being
truncated.
This can result in an inappropriate -EINVAL failure or in reporting for an
incorrect span of CPUs.
Fixes: f9fd8914c1ac ("[PATCH] per-task delay accounting taskstats interface: control exit data through cpumasks")
Reported-by: Oleg Deomi <oleg.deomi@gmail.com>
Closes: https://lore.kernel.org/CAByWkfZ6b1=3H9pwkz-dDQOs9cZaF-HYQ6b9Yb0=Hq2r1Vv_Pw@mail.gmail.com
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
kernel/taskstats.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/kernel/taskstats.c~a
+++ a/kernel/taskstats.c
@@ -368,7 +368,7 @@ static int parse(struct nlattr *na, stru
return -E2BIG;
if (len < 1)
return -EINVAL;
- data = kmalloc(len, GFP_KERNEL);
+ data = kmalloc(len + 1, GFP_KERNEL);
if (!data)
return -ENOMEM;
nla_strscpy(data, na, len);
_
next prev parent reply other threads:[~2026-07-21 23:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 12:52 Oleg Deomi
2026-07-21 23:38 ` Andrew Morton [this message]
2026-07-23 13:04 ` Bradley Morgan
2026-07-23 19:28 ` Andrew Morton
2026-07-23 21:11 ` Bradley Morgan
2026-07-23 23:17 ` Andrew Morton
2026-07-23 23:19 ` Bradley Morgan
2026-07-24 15:32 ` Bradley Morgan
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=20260721163842.f08e18db987a749251cfa367@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=bsingharora@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg.deomi@gmail.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®