All Virtuozzo development lists (kernel + QEMU)
 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.1 1/2] dm-ploop: stop enospc_timer in ploop_destroy()
Date: Tue, 10 Nov 2026 18:03:39 +0100	[thread overview]
Message-ID: <179433021952.3552165.16408029362614329367.b4-review@b4> (raw)
In-Reply-To: <20261109190657.1851487-2-den@openvz.org>

I won't apply this version, please send v2 with the changes below.

On Mon, 9 Nov 2026 20:06:56 +0100, Denis V. Lunev wrote:
> The destructor never stops enospc_timer. ploop_presuspend() deletes it
> with timer_delete_sync_try(), which does not wait for a callback that
> runs on another CPU, and ploop_try_delay_enospc() tests wants_suspend
> without deferred_lock, so a write that fails with ENOSPC around the
> presuspend can arm the timer again. The callback dereferences the
> struct ploop that ploop_dtr() frees.

- Item 2 of the cover letter reply: the race is mod_timer() after the
  test, and the message should say what the user gets.

The lockless test is not the cause. In 6ddad5a4d226 the test was under
deferred_lock, but mod_timer() ran after the unlock, so the timer could
be armed after presuspend's timer_delete_sync_try() from the start.
That is also why the Fixes tag is right.

"does not wait for a callback that runs on another CPU" can go: a
callback that runs during presuspend is done long before dtr.

Say what happens then: the timer expires on freed memory, and with
patch 2 it also calls wake_up_process() on a freed task.

The paragraph is one sentence chained with commas; something like:

    The destructor never stops enospc_timer. ploop_try_delay_enospc()
    arms it after testing wants_suspend, and nothing orders that against
    timer_delete_sync_try() in ploop_presuspend(). A write that fails
    with ENOSPC around the presuspend leaves the timer pending after the
    suspend, and it expires on the struct ploop that ploop_dtr() freed.

>  	if (ploop->kt_worker) {
> +		timer_shutdown_sync(&ploop->enospc_timer);
>  		ploop->force_md_writeback = 1;

- Item 1 of the cover letter reply: cancel event_work here too.

ploop_try_delay_enospc() calls schedule_work(&ploop->event_work) right
after mod_timer(), so the same race queues event_work after
presuspend's flush_work(). Nothing in ploop_destroy() waits for it,
and do_ploop_event_work() reads ploop->ti after the free. The window
is much shorter than the timer's, but it is the same race:

    timer_shutdown_sync(&ploop->enospc_timer);
    cancel_work_sync(&ploop->event_work);

INIT_WORK() runs before kt_worker is created, so it is valid under the
same check.

-- 
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-10 17:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 19:06 [Devel] [PATCH hci-8.1 0/2] dm-ploop: fix writes held on ENOSPC never being retried Denis V. Lunev
2026-11-09 19:06 ` [Devel] [PATCH hci-8.1 1/2] dm-ploop: stop enospc_timer in ploop_destroy() Denis V. Lunev
2026-11-09 19:17   ` no-reply
2026-11-10 17:03   ` Konstantin Khorenko [this message]
2026-11-09 19:06 ` [Devel] [PATCH hci-8.1 2/2] dm-ploop: fix the ENOSPC retry timer not waking the dispatcher Denis V. Lunev
2026-11-09 19:18   ` no-reply
2026-11-10 17:03   ` Konstantin Khorenko
2026-11-10 17:03 ` [Devel] [PATCH hci-8.1 0/2] dm-ploop: fix writes held on ENOSPC never being retried 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=179433021952.3552165.16408029362614329367.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.