OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 v5 1/3] dm-qcow2: add qcow2_md_page_read_sync() helper
Date: Wed, 21 Oct 2026 17:42:02 +0200	[thread overview]
Message-ID: <179259732233.3864599.11791979123677362750.b4-review@b4> (raw)
In-Reply-To: <20261010124642.927044-2-alexander.ivanov@virtuozzo.com>

> + * The caller must ensure no read of this page is in flight
> + * (e.g., the device is suspended): if the page is cached but
> + * not MD_UPTODATE yet, qcow2_md_page_find_or_postpone() returns
> + * NULL and the following insert fails.

The requirement is stronger: nobody else may look this page up while
the helper runs. A qio that finds the page before MD_UPTODATE is set
gets queued on md->wait_list, which this helper never wakes. On the
error path the page is freed with that qio still on it. Neither caller
can hit this today, but the comment should say "no concurrent lookup"
rather than "no read in flight".

> +     ret = qcow2_rw_page_sync(READ, qcow2, id, (*md)->page);
> +     spin_lock_irq(&qcow2->md_pages_lock);
> +     if (ret)
> +             qcow2_md_page_erase(qcow2, *md);
> +     else
> +             (*md)->status |= MD_UPTODATE;
> +     spin_unlock_irq(&qcow2->md_pages_lock);
> +     if (ret)
> +             qcow2_free_md_page(*md);
> +     return ret;

On both error paths *md is left pointing to freed memory: here, and on
-EEXIST from qcow2_alloc_and_insert_md_page(). Please set *md = NULL
there.

-- 
Konstantin Khorenko <khorenko@virtuozzo.com>
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-10-21 15:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-10 12:46 [Devel] [PATCH hci-8.1 v5 0/3] dm-qcow2: truncate unused tail of image on suspend Alexander Ivanov
2026-10-10 12:46 ` [Devel] [PATCH hci-8.1 v5 1/3] dm-qcow2: add qcow2_md_page_read_sync() helper Alexander Ivanov
2026-10-10 12:51   ` no-reply
2026-10-21 15:42   ` Konstantin Khorenko [this message]
2026-10-10 12:46 ` [Devel] [PATCH hci-8.1 v5 2/3] dm-qcow2: drop duplicate prefix from QC_ERR/QC_INFO messages Alexander Ivanov
2026-10-10 12:50   ` no-reply
2026-10-21 15:42   ` Konstantin Khorenko
2026-10-10 12:46 ` [Devel] [PATCH hci-8.1 v5 3/3] dm-qcow2: truncate unused tail of image on suspend Alexander Ivanov
2026-10-10 12:53   ` no-reply
2026-10-12  9:35   ` Andrey Zhadchenko
2026-10-21 15:42   ` Konstantin Khorenko
2026-10-21 17:53     ` Denis V. Lunev
2026-10-22  8:35     ` Alexander Ivanov
2026-10-12  9:59 ` [Devel] [PATCH hci-8.1 v5 0/3] " Andrey Zhadchenko
2026-10-21 15:42 ` Konstantin Khorenko

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=179259732233.3864599.11791979123677362750.b4-review@b4 \
    --to=khorenko@virtuozzo.com \
    --cc=alexander.ivanov@virtuozzo.com \
    --cc=devel@openvz.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