public inbox for patches@lists.linux.dev
 help / color / mirror / Atom feed
From: Reinette Chatre <reinette.chatre@intel.com>
To: Borislav Petkov <bp@alien8.de>
Cc: <tony.luck@intel.com>, <james.morse@arm.com>,
	<Dave.Martin@arm.com>, <babu.moger@amd.com>, <tglx@linutronix.de>,
	<dave.hansen@linux.intel.com>, <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>
Subject: Re: [PATCH v3 03/13] fs/resctrl: Avoid "may be used uninitialized" warning
Date: Tue, 7 Apr 2026 13:50:50 -0700	[thread overview]
Message-ID: <e89edbdb-b6a4-453f-99da-41991ad25712@intel.com> (raw)
In-Reply-To: <20260407185543.GFadVTLy82sBzT3eej@fat_crate.local>

Hi Boris,

Thank you very much for taking a look.

On 4/7/26 11:55 AM, Borislav Petkov wrote:
> On Tue, Apr 07, 2026 at 09:02:00AM -0700, Reinette Chatre wrote:
>> Building resctrl with extra checks ("W=12") produces the following warning:
>>  .../include/linux/ucopysize.h:22:17: warning: ‘buf’ may be used uninitialized [-Wmaybe-uninitialized]
>>    22 |                 __check_object_size(ptr, n, to_user);
>>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>  .../include/linux/ucopysize.h: In function ‘pseudo_lock_measure_trigger’:
>>  .../include/linux/ucopysize.h:10:13: note: by argument 1 of type ‘const void *’ to ‘__check_object_size’ declared here
>>    10 | extern void __check_object_size(const void *ptr, unsigned long n,
>>       |             ^~~~~~~~~~~~~~~~~~~
>>  .../fs/resctrl/pseudo_lock.c:754:14: note: ‘buf’ declared here
>>   754 |         char buf[32];
>>       |              ^~~
>>
>> __check_object_size() ensures the provided buffer is within a valid location
>> but does not read from the uninitialized buffer. Even so, initialize the
>> buffer to silence the warning to help resctrl have a cleaner build.
>>
>> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
>> ---
>>  fs/resctrl/pseudo_lock.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/resctrl/pseudo_lock.c b/fs/resctrl/pseudo_lock.c
>> index fa3687d69ebd..e1e9134474f4 100644
>> --- a/fs/resctrl/pseudo_lock.c
>> +++ b/fs/resctrl/pseudo_lock.c
>> @@ -750,8 +750,8 @@ static ssize_t pseudo_lock_measure_trigger(struct file *file,
>>  					   size_t count, loff_t *ppos)
>>  {
>>  	struct rdtgroup *rdtgrp = file->private_data;
>> +	char buf[32] = {};
> 
> AFAIU, you're not leaking any uninitialized stack data from that buffer,
> right?

Right. From what I can tell __check_object_size() just checks that the address
is from a valid region and does not read from the buffer.

> 
> If so, why do you care about some silly build warning and are willing to waste
> a 32-byte memset on every function entry?

I care because I am including a W=12 build as part of checking all resctrl patches
and having this be the one and only warning that always shows up is distracting.
Removing it to accomplish a clean W=12 build does not seem impactful to me.

Of course you are right that this wastes a memset. This function is not on a
hot path though and I do not believe it would be called frequently since it is
intended to demonstrate how successful the setup of a pseudo-lock region was and
successive calls should produce consistent results.

> 
> There's a reason those warnings are behind W= ...

Indeed. This patch is for developer and maintenance convenience and not required for
resctrl health. No problem from me if you find it not to be appropriate. I will just
continue to parse the warning out of the logs.

Reinette

  reply	other threads:[~2026-04-07 20:50 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-07 16:01 [PATCH v3 00/13] x86,fs/resctrl: Improve resctrl quality and consistency Reinette Chatre
2026-04-07 16:01 ` [PATCH v3 01/13] MAINTAINERS: Update resctrl entry Reinette Chatre
2026-04-07 16:01 ` [PATCH v3 02/13] fs/resctrl: Add missing return value descriptions Reinette Chatre
2026-04-07 16:02 ` [PATCH v3 03/13] fs/resctrl: Avoid "may be used uninitialized" warning Reinette Chatre
2026-04-07 18:55   ` Borislav Petkov
2026-04-07 20:50     ` Reinette Chatre [this message]
2026-04-07 22:19       ` Borislav Petkov
2026-04-07 22:56         ` Reinette Chatre
2026-04-07 16:02 ` [PATCH v3 04/13] fs/resctrl: Use correct format specifier for printing error pointers Reinette Chatre
2026-04-07 16:02 ` [PATCH v3 05/13] x86/resctrl: Protect against bad shift Reinette Chatre
2026-04-08 16:37   ` Reinette Chatre
2026-04-07 16:02 ` [PATCH v3 06/13] fs/resctrl: Change pattern used to track number of entries in enum Reinette Chatre
2026-04-07 16:02 ` [PATCH v3 07/13] fs/resctrl: Use accurate type for rdt_resource::rid Reinette Chatre
2026-04-07 16:02 ` [PATCH v3 08/13] fs/resctrl: Pass error reading event through to user space Reinette Chatre
2026-04-07 16:02 ` [PATCH v3 09/13] fs/resctrl: Add last_cmd_status support for writes to max_threshold_occupancy Reinette Chatre
2026-04-07 16:02 ` [PATCH v3 10/13] fs/resctrl: Use accurate and symmetric exit flows Reinette Chatre
2026-04-07 16:02 ` [PATCH v3 11/13] fs/resctrl: Change last_cmd_status custom during input parsing Reinette Chatre
2026-04-07 16:02 ` [PATCH v3 12/13] fs/resctrl: Communicate resource group deleted error via last_cmd_status Reinette Chatre
2026-04-07 16:02 ` [PATCH v3 13/13] fs/resctrl: Inform user space when status buffer overflowed Reinette Chatre

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=e89edbdb-b6a4-453f-99da-41991ad25712@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=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