From: Borislav Petkov <bp@alien8.de>
To: Reinette Chatre <reinette.chatre@intel.com>
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 15:44:29 +0200 [thread overview]
Message-ID: <20190620134429.GD28032@zn.tnic> (raw)
In-Reply-To: <58c9b6081fd9bf599af0dfc01a6fdd335768efef.1560975645.git.reinette.chatre@intel.com>
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.
Thx.
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
next prev parent reply other threads:[~2019-06-20 13:44 UTC|newest]
Thread overview: 7+ 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 [this message]
2019-06-20 23:24 ` Reinette Chatre
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
[not found] ` <20190622181348.648872084E@mail.kernel.org>
2019-06-24 19:48 ` 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=20190620134429.GD28032@zn.tnic \
--to=bp@alien8.de \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=reinette.chatre@intel.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;
as well as URLs for NNTP newsgroup(s).