From: Reinette Chatre <reinette.chatre@intel.com>
To: <tony.luck@intel.com>, <james.morse@arm.com>,
<Dave.Martin@arm.com>, <babu.moger@amd.com>, <bp@alien8.de>,
<tglx@linutronix.de>, <dave.hansen@linux.intel.com>
Cc: <x86@kernel.org>, <hpa@zytor.com>, <ben.horgan@arm.com>,
<fustini@kernel.org>, <fenghuay@nvidia.com>,
<peternewman@google.com>, <linux-kernel@vger.kernel.org>,
<patches@lists.linux.dev>, Chris Samuel <chris@csamuel.org>
Subject: Re: [PATCH v2 11/14] fs/resctrl: Use stricter checks on input to cpus/cpus_list file
Date: Wed, 25 Mar 2026 11:18:53 -0700 [thread overview]
Message-ID: <0361e817-b673-4108-95df-c22d0795323d@intel.com> (raw)
In-Reply-To: <744ddfbc6365832a5707b4d1631158f42e121401.1774043709.git.reinette.chatre@intel.com>
On 3/20/26 3:03 PM, Reinette Chatre wrote:
> Callbacks handling writes to resctrl files are called via
> kernfs_fop_write_iter() that ensures that the resctrl callback is never
> called with a NULL buffer. Even if user space issues a write() with a NULL
> buffer and zero count the resctrl callback receives a valid buffer
> terminated with '\0' and the number of bytes parameter set to zero.
>
> The NULL buffer check at the beginning of rdtgroup_cpus_write(), while
> making no assumptions about caller behavior, is not useful. An empty
> buffer is transformed into an empty cpumask that is passed through entire
> flow that results in no changes.
>
> Ensure that the user provided buffer contains some data before attempting
> to parse it using the same check as other resctrl files (the familiar
> "nbytes == 0"). The custom is for resctrl file callbacks to fail on an
> empty buffer and this brings interactions with the cpus/cpus_list file in
> line with this custom. The risk is that if there exists a user space that
> uses empty writes to this specific file then those successful interactions
> will start failing.
>
> Exit right away if there was no failure yet no cpumask could be created
> from the input. It is of no use to pass an empty cpumask through the
> entire flow, just return with success to short-circuit the existing
> behavior.
>
> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
> ---
Chris Samuel reported that this breaks a legitimate use case where user space
could use an empty write, for example write(fd, NULL, 0), to remove all CPUs
from a resource group.
This change thus ended up being too strict and should be dropped.
Reinette
next prev parent reply other threads:[~2026-03-25 18:19 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 22:03 [PATCH v2 00/14] x86,fs/resctrl: Improve resctrl quality and consistency Reinette Chatre
2026-03-20 22:03 ` [PATCH v2 01/14] MAINTAINERS: Update resctrl entry Reinette Chatre
2026-03-20 22:03 ` [PATCH v2 02/14] fs/resctrl: Add missing return value descriptions Reinette Chatre
2026-03-20 22:03 ` [PATCH v2 03/14] fs/resctrl: Avoid "may be used uninitialized" warning Reinette Chatre
2026-03-20 22:03 ` [PATCH v2 04/14] fs/resctrl: Use correct format specifier for printing error pointers Reinette Chatre
2026-03-20 22:03 ` [PATCH v2 05/14] x86/resctrl: Protect against bad shift Reinette Chatre
2026-03-20 22:03 ` [PATCH v2 06/14] fs/resctrl: Change pattern used to track number of entries in enum Reinette Chatre
2026-03-23 10:53 ` Ben Horgan
2026-03-20 22:03 ` [PATCH v2 07/14] fs/resctrl: Use accurate type for rdt_resource::rid Reinette Chatre
2026-03-23 10:54 ` Ben Horgan
2026-03-20 22:03 ` [PATCH v2 08/14] fs/resctrl: Pass error reading event through to user space Reinette Chatre
2026-03-20 22:03 ` [PATCH v2 09/14] fs/resctrl: Add last_cmd_status support for writes to max_threshold_occupancy Reinette Chatre
2026-03-23 9:14 ` Chen, Yu C
2026-03-23 16:56 ` Reinette Chatre
2026-03-20 22:03 ` [PATCH v2 10/14] fs/resctrl: Use accurate and symmetric exit flows Reinette Chatre
2026-03-20 22:03 ` [PATCH v2 11/14] fs/resctrl: Use stricter checks on input to cpus/cpus_list file Reinette Chatre
2026-03-25 18:18 ` Reinette Chatre [this message]
2026-03-20 22:03 ` [PATCH v2 12/14] fs/resctrl: Change last_cmd_status custom during input parsing Reinette Chatre
2026-03-20 22:03 ` [PATCH v2 13/14] fs/resctrl: Communicate resource group deleted error via last_cmd_status Reinette Chatre
2026-03-20 22:03 ` [PATCH v2 14/14] fs/resctrl: Inform user space when status buffer overflowed Reinette Chatre
2026-03-23 10:49 ` Ben Horgan
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=0361e817-b673-4108-95df-c22d0795323d@intel.com \
--to=reinette.chatre@intel.com \
--cc=Dave.Martin@arm.com \
--cc=babu.moger@amd.com \
--cc=ben.horgan@arm.com \
--cc=bp@alien8.de \
--cc=chris@csamuel.org \
--cc=dave.hansen@linux.intel.com \
--cc=fenghuay@nvidia.com \
--cc=fustini@kernel.org \
--cc=hpa@zytor.com \
--cc=james.morse@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=peternewman@google.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=x86@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox