mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rodolfo Giometti <giometti@enneenne.com>
To: Danish Khateeb <danishkhateeb03@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Calvin Owens <calvin@wbinvd.org>, Yibo Tan <lhfff@tju.edu.cn>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 0/4] pps: generators: fix use-after-free on unregister with the file open
Date: Wed, 30 Sep 2026 14:07:55 +0200	[thread overview]
Message-ID: <1888e57b-8e0d-46c2-87d4-d65080e9ebbd@enneenne.com> (raw)
In-Reply-To: <20260929124937.51114-1-danishkhateeb03@gmail.com>

On Tue, 29 Sep 2026 07:49:33 -0500, Danish Khateeb wrote:
> This fixes what goes wrong when a PPS generator is unregistered while
> userspace is using it:
>
> 1/4: closing the file frees pps_gen in ->release(), and __fput() then
> calls cdev_put() on the cdev embedded in it. pps.c had the same bug
> before commit c79a39dc8d06 ("pps: Fix a use-after-free"). Fixed with
> cdev_device_add().
>
> 2/4: the ioctls keep using the driver's pps_gen_source_info: TIO's devm
> memory after an unbind, and pps_gen-dummy's module data and code after
> an rmmod. They now return -ENODEV, as PPS_KC_BIND does for a removed
> PPS device since commit 3649f9a6b897.
>
> 3/4: a PPS_GEN_SETENABLE, or a write to "enable", between the driver
> stopping its timer and the unregister starts the timer again, and it
> then outlives the driver. The core now stops the generator on
> unregister.
>
> 4/4: a reader in PPS_GEN_FETCHEVENT is now woken up on unregister and
> gets -ENODEV, instead of sleeping until a signal.
>
> Yibo Tan's "pps: generators: Pin dummy provider while a file is open"
> [1] keeps the dummy module loaded while its file is open. That covers
> only the dummy rmmod case; a device such as TIO can still be unbound,
> so 2/4 is needed either way.
>
> Changes in v2:
> - New 3/4 and 4/4, suggested by Rodolfo.
> - 1/4 and 2/4 are unchanged.
> - v1: https://lore.kernel.org/all/20260929022219.212024-1-danishkhateeb03@gmail.com/
>
> [1] https://lore.kernel.org/all/20260911134952.648064-1-lhfff@tju.edu.cn/
>
> Danish Khateeb (4):
>   pps: generators: fix use-after-free when closing a removed device
>   pps: generators: don't use the driver's info after unregister
>   pps: generators: stop the generator on unregister
>   pps: generators: wake up PPS_GEN_FETCHEVENT readers on unregister
>
>  drivers/pps/generators/pps_gen.c | 111 ++++++++++++++++++++-----------
>  include/linux/pps_gen_kernel.h   |   4 +-
>  2 files changed, 76 insertions(+), 39 deletions(-)
>
>
> base-commit: 72d3fcf802c45d00b300f25b848a93c3a2bd7c7e

Thanks for picking up both points, and for testing them.

For the whole series:

Acked-by: Rodolfo Giometti <giometti@enneenne.com>

Ciao,

Rodolfo

      parent reply	other threads:[~2026-09-30 12:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29 12:49 Danish Khateeb
2026-09-29 12:49 ` [PATCH v2 1/4] pps: generators: fix use-after-free when closing a removed device Danish Khateeb
2026-09-30 12:07   ` Rodolfo Giometti
2026-09-29 12:49 ` [PATCH v2 2/4] pps: generators: don't use the driver's info after unregister Danish Khateeb
2026-09-30 12:09   ` Rodolfo Giometti
2026-09-29 12:49 ` [PATCH v2 3/4] pps: generators: stop the generator on unregister Danish Khateeb
2026-09-30 12:10   ` Rodolfo Giometti
2026-09-29 12:49 ` [PATCH v2 4/4] pps: generators: wake up PPS_GEN_FETCHEVENT readers " Danish Khateeb
2026-09-30 12:10   ` Rodolfo Giometti
2026-09-30 12:07 ` Rodolfo Giometti [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=1888e57b-8e0d-46c2-87d4-d65080e9ebbd@enneenne.com \
    --to=giometti@enneenne.com \
    --cc=akpm@linux-foundation.org \
    --cc=calvin@wbinvd.org \
    --cc=danishkhateeb03@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=lhfff@tju.edu.cn \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®