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]
Message-ID: <CAHUa44G_z0b42kHcaxvRJOou=pPT+MgWkJ5-5kbEOdJOFLMsAA@mail.gmail.com>
Date: Wed, 26 Mar 2025 07:59:08 +0100
From: Jens Wiklander <jens.wiklander@...aro.org>
To: Marco Felsch <m.felsch@...gutronix.de>
Cc: sumit.garg@...nel.org, vbabka@...e.cz, akpm@...ux-foundation.org, 
	willy@...radead.org, kernel@...gutronix.de, op-tee@...ts.trustedfirmware.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] tee: shm: fix slab page refcounting

Hi Marco,

On Tue, Mar 25, 2025 at 9:07 PM Marco Felsch <m.felsch@...gutronix.de> wrote:
>
> Skip manipulating the refcount in case of slab pages according commit
> b9c0e49abfca ("mm: decline to manipulate the refcount on a slab page").
>
> Fixes: b9c0e49abfca ("mm: decline to manipulate the refcount on a slab page")
> Signed-off-by: Marco Felsch <m.felsch@...gutronix.de>
> ---
> v2:
> - Make use of page variable
> v1:
> - https://lore.kernel.org/all/20250325195021.3589797-1-m.felsch@pengutronix.de/
>
>  drivers/tee/tee_shm.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c
> index daf6e5cfd59a..35f0ac359b12 100644
> --- a/drivers/tee/tee_shm.c
> +++ b/drivers/tee/tee_shm.c
> @@ -19,16 +19,24 @@ static void shm_put_kernel_pages(struct page **pages, size_t page_count)
>  {
>         size_t n;
>
> -       for (n = 0; n < page_count; n++)
> -               put_page(pages[n]);
> +       for (n = 0; n < page_count; n++) {
> +               struct page *page = pages[n];
> +
> +               if (!PageSlab(page))
> +                       put_page(page);
> +       }
>  }
>
>  static void shm_get_kernel_pages(struct page **pages, size_t page_count)
>  {
>         size_t n;
>
> -       for (n = 0; n < page_count; n++)
> -               get_page(pages[n]);
> +       for (n = 0; n < page_count; n++) {
> +               struct page *page = pages[n];
> +
> +               if (!PageSlab(page))
> +                       get_page(page);

b9c0e49abfca ("mm: decline to manipulate the refcount on a slab page")
mentions that more page types will have a zero refcount in the longer
term. So we'll need to add exception after exception here. Is there a
helper function somewhere to get all the pages we need? Or can we do
this differently?

Cheers,
Jens

> +       }
>  }
>
>  static void release_registered_pages(struct tee_shm *shm)
> --
> 2.39.5
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ