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: <ZvGar7f5IcMiFzKk@skv.local>
Date: Mon, 23 Sep 2024 19:43:27 +0300
From: Andrey Skvortsov <andrej.skvortzov@...il.com>
To: Sergey Senozhatsky <senozhatsky@...omium.org>
Cc: Venkat Rao Bagalkote <venkat88@...ux.vnet.ibm.com>,
	Minchan Kim <minchan@...nel.org>, Jens Axboe <axboe@...nel.dk>,
	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org, linux-block@...r.kernel.org,
	stable@...r.kernel.org
Subject: Re: [PATCH] zram: don't free statically defined names

On 24-09-24 01:07, Sergey Senozhatsky wrote:
> On (24/09/23 18:55), Andrey Skvortsov wrote:
> [..]
> > > Ugh, I know what's happening.  You don't have CONFIG_ZRAM_MULTI_COMP
> > > so that ZRAM_PRIMARY_COMP and ZRAM_SECONDARY_COMP are the same thing.
> > > Yeah, that all makes sense now, I haven't thought about it.
> > 
> > yes, I don't have CONFIG_ZRAM_MULTI_COMP set. I'll include your
> > comment into commit description for v2.
> 
> Thanks.
> 
> Can you do it something like the diff below?  Let's iterate
> ->comp_algs from ZRAM_PRIMARY_COMP.  I don't really mind the
> "Do not free statically defined" comment, up to you.
> 
> And the commit message probably can stay that: on !CONFIG_ZRAM_MULTI_COMP
> systems ZRAM_SECONDARY_COMP can hold default_compressor, because it's
> the same offset as ZRAM_PRIMARY_COMP, so we need to make sure that we
> don't attempt to kfree() the statically defined comp name.
> 
> ---
> 
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index c3d245617083..ad9c9bc3ccfc 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -2115,8 +2115,10 @@ static void zram_destroy_comps(struct zram *zram)
>                 zram->num_active_comps--;
>         }
>  
> -       for (prio = ZRAM_SECONDARY_COMP; prio < ZRAM_MAX_COMPS; prio++) {
> -               kfree(zram->comp_algs[prio]);
> +       for (prio = ZRAM_PRIMARY_COMP; prio < ZRAM_MAX_COMPS; prio++) {
> +               /* Do not free statically defined compression algorithms */
> +               if (zram->comp_algs[prio] != default_compressor)
> +                       kfree(zram->comp_algs[prio]);
>                 zram->comp_algs[prio] = NULL;
>         }
Sorry, I've seen you comment after I've sent v2. I'll do this in v3. 

-- 
Best regards,
Andrey Skvortsov

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ