public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Ming Lei <ming.lei@redhat.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
	linux-block@vger.kernel.org
Subject: Re: [bug report] zram: avoid race between zram_remove and disksize_store
Date: Fri, 5 Nov 2021 12:18:14 +0300	[thread overview]
Message-ID: <20211105091638.GA2026@kadam> (raw)
In-Reply-To: <YYR5fmwmfvfQzWuZ@T590>

On Fri, Nov 05, 2021 at 08:23:26AM +0800, Ming Lei wrote:
> > --> 2044         zram_reset_device(zram);
> > 
> > This double frees it.
> 
> No.
> 
> Inside zram_reset_device(), if init_done()(zram->disksize) is zero, zram_reset_device()
> returns immediately, otherwise zram->disksize is cleared and zram_meta_free()
> is run in zram_reset_device(). Meantime zram->init_lock protects the
> reset and disksize_store().
> 
> The 2nd zram_reset_device() can only reset device if disksize_store() sets new
> zram->disksize and allocates new meta after the 1st zram_reset_device().
> 
> Seems smatch static checker need to be improved to cover this case?

Yep.  It's a bug in Smatch.  It's supposed to parse this correctly.

I will investigate.  Thanks!

regards,
dan carpenter


      reply	other threads:[~2021-11-05  9:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-04 11:48 [bug report] zram: avoid race between zram_remove and disksize_store Dan Carpenter
2021-11-04 11:49 ` Dan Carpenter
2021-11-05  0:23 ` Ming Lei
2021-11-05  9:18   ` Dan Carpenter [this message]

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=20211105091638.GA2026@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=senozhatsky@chromium.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