OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: "Denis V. Lunev" <den@openvz.org>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.2] dm-ploop: fix an ENOSPC endio arming the timer on a freed ploop
Date: Thu, 19 Nov 2026 17:19:49 +0100	[thread overview]
Message-ID: <179510518988.1461989.17561253528990728836.b4-review@b4> (raw)
In-Reply-To: <20261118190006.3573492-1-den@openvz.org>

Applying with these fixes on my side:
- Fixes: 6ddad5a4d226 -> 90bb85536272, the driver add in this branch;
  6ddad5a4d226 is not reachable from it
- "The endio does not touch the struct ploop after the unlock" ->
  "ploop_try_delay_enospc() does not touch the struct ploop after the
  unlock": its callers still do, see below
- the first paragraph split before "An endio that stalls"

Separate patches, not needed for this one. I created a task for each:

1. After the request completes, a split write still frees the child
   pio into ploop->pio_pool in ploop_do_pio_endio(), and a write that
   allocated a cluster still runs ploop_bat_write_finish() and
   ploop_put_piwb() on the ploop. From an async fs completion this can
   run after ploop_destroy(); not specific to ENOSPC and older than
   this patch.
   https://virtuozzo.atlassian.net/browse/VSTOR-155932
2. dm-qcow2 has the same window: qcow2_try_delay_enospc() arms
   enospc_timer and queues event_work after dropping event_lock, and
   the destroy path neither shuts the timer down nor cancels the work.
   https://virtuozzo.atlassian.net/browse/VSTOR-155933

On Wed, 18 Nov 2026 20:00:06 +0100, Denis V. Lunev wrote:
> Hold deferred_lock from the wants_suspend test through schedule_work().
> ploop_presuspend() sets wants_suspend under the same lock, so either it
> finds the pio on enospc_pios with the timer and the work already armed,
> or the endio sees wants_suspend and leaves the request to its caller to
> complete. The endio does not touch the struct ploop after the unlock.

The fix itself is right: no lock order or context problem, and
nothing calls an endio under deferred_lock.

> 	pr_err_once(PL_FMT("underlying disk is almost full"),
> 		ploop_device_name(ploop));

Alexander suggested taking this pr_err_once() out from under the
lock. I keep it where the patch has it; the options were:

- After the unlock: no. ploop_device_name() reads ploop->ti->table,
  the md and disk->disk_name. Once the pio is on enospc_pios,
  presuspend can resubmit it, the request complete and a remove free
  all of them, so the first ENOSPC delay after module load could read
  freed memory: the use-after-free this patch closes.
- Copy the name into a DISK_NAME_LEN buffer under the lock and print
  after the unlock: correct, but it copies the name on every delayed
  pio, or needs a "once" flag of its own, for a message printed once.
- Before spin_lock_irqsave(): safe, the request pins the device until
  the pio is queued, but the message then also comes on the
  wants_suspend path, which does not delay the pio.
- Under the lock, as now: printk is fine with interrupts off and the
  console path does not take deferred_lock; the cost is one console
  write under the lock, once per module load.

Thanks.

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-11-19 16:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 19:00 Denis V. Lunev
2026-11-18 19:05 ` no-reply
2026-11-19  8:00 ` Alexander Ivanov
2026-11-19 16:19 ` Konstantin Khorenko [this message]
2026-11-19 16:20 ` 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=179510518988.1461989.17561253528990728836.b4-review@b4 \
    --to=khorenko@virtuozzo.com \
    --cc=den@openvz.org \
    --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