lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 11 Dec 2019 01:23:34 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc:     Arnaldo Carvalho de Melo <acme@...hat.com>,
        Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org,
        Jiri Olsa <jolsa@...nel.org>
Subject: Re: [PATCH 2/2] perf/x86/intel/bts: Fix the use of page_private()

On Thu, Dec 05, 2019 at 05:28:53PM +0300, Alexander Shishkin wrote:
> Commit
> 
>   8062382c8dbe2 ("perf/x86/intel/bts: Add BTS PMU driver")
> 
> uses page_private(page) without checking the PagePrivate(page) first,
> which seems like a potential bug, considering that page->private aliases
> with other stuff in struct page.
> 
> Fix this by checking PagePrivate() first.
> 
> Signed-off-by: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
> Fixes: 8062382c8dbe2 ("perf/x86/intel/bts: Add BTS PMU driver")
> ---
>  arch/x86/events/intel/bts.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
> index d53b4fb86d87..9e4da1c5a129 100644
> --- a/arch/x86/events/intel/bts.c
> +++ b/arch/x86/events/intel/bts.c
> @@ -63,9 +63,17 @@ struct bts_buffer {
>  
>  static struct pmu bts_pmu;
>  
> +static int buf_nr_pages(struct page *page)
> +{
> +	if (!PagePrivate(page))
> +		return 1;
> +
> +	return 1 << page_private(page);
> +}
> +
>  static size_t buf_size(struct page *page)
>  {
> -	return 1 << (PAGE_SHIFT + page_private(page));
> +	return 1 << (PAGE_SHIFT + buf_nr_pages(page));

Hurmph, shouldn't that be:

	return buf_nr_pages(page) * PAGE_SIZE;

?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ