public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Reinette Chatre <reinette.chatre@intel.com>
To: Borislav Petkov <bp@alien8.de>
Cc: tglx@linutronix.de, fenghua.yu@intel.com, tony.luck@intel.com,
	mingo@redhat.com, hpa@zytor.com, x86@kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] x86/resctrl: Prevent possible overrun during bitmap operations
Date: Thu, 20 Jun 2019 16:24:42 -0700	[thread overview]
Message-ID: <46d134b4-8c13-1485-e0a1-4a165cc9b727@intel.com> (raw)
In-Reply-To: <20190620134429.GD28032@zn.tnic>

Hi Borislav,

On 6/20/2019 6:44 AM, Borislav Petkov wrote:
> On Wed, Jun 19, 2019 at 01:27:16PM -0700, Reinette Chatre wrote:
>> @@ -2494,26 +2498,19 @@ static int mkdir_mondata_all(struct kernfs_node *parent_kn,
>>   */
>>  static void cbm_ensure_valid(u32 *_val, struct rdt_resource *r)
>>  {
>> -	/*
>> -	 * Convert the u32 _val to an unsigned long required by all the bit
>> -	 * operations within this function. No more than 32 bits of this
>> -	 * converted value can be accessed because all bit operations are
>> -	 * additionally provided with cbm_len that is initialized during
>> -	 * hardware enumeration using five bits from the EAX register and
>> -	 * thus never can exceed 32 bits.
>> -	 */
>> -	unsigned long *val = (unsigned long *)_val;
>> +	unsigned long val = *_val;
>>  	unsigned int cbm_len = r->cache.cbm_len;
>>  	unsigned long first_bit, zero_bit;
> 
> Please sort function local variables declaration in a reverse christmas
> tree order:
> 
> 	<type A> longest_variable_name;
> 	<type B> shorter_var_name;
> 	<type C> even_shorter;
> 	<type D> i;
> 
>> -	if (*val == 0)
>> +	if (val == 0)
> 
> 	if (!val)
> 
>>  		return;
>>  
>> -	first_bit = find_first_bit(val, cbm_len);
>> -	zero_bit = find_next_zero_bit(val, cbm_len, first_bit);
>> +	first_bit = find_first_bit(&val, cbm_len);
>> +	zero_bit = find_next_zero_bit(&val, cbm_len, first_bit);
>>  
>>  	/* Clear any remaining bits to ensure contiguous region */
>> -	bitmap_clear(val, zero_bit, cbm_len - zero_bit);
>> +	bitmap_clear(&val, zero_bit, cbm_len - zero_bit);
>> +	*_val = (u32)val;
> 
> ... and also, that function should simply return the u32 value instead
> of using @_val as an input and output var.
> 
> But that should be a separate cleanup patch anyway.

Thank you very much. I will provide that separate cleanup patch.

Reinette


  reply	other threads:[~2019-06-20 23:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-19 20:27 [PATCH] x86/resctrl: Prevent possible overrun during bitmap operations Reinette Chatre
2019-06-20 13:44 ` Borislav Petkov
2019-06-20 23:24   ` Reinette Chatre [this message]
2019-06-20 13:49 ` [tip:x86/urgent] " tip-bot for Reinette Chatre
2019-06-24 13:55 ` [PATCH] " David Laight
2019-06-24 18:19   ` 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=46d134b4-8c13-1485-e0a1-4a165cc9b727@intel.com \
    --to=reinette.chatre@intel.com \
    --cc=bp@alien8.de \
    --cc=fenghua.yu@intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=stable@vger.kernel.org \
    --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