[Devel] [PATCH VZ10 v2] fs/fuse kio: track pending kRPC connect via state machine, not a pointer
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Sep 4 12:06:00 MSK 2026
> Rework the previous fix ("fs/fuse kio: fix kRPC connect issues") to not
> require the new struct pcs_krpc member "connect_req", so the fix can be
> shipped as a livepatch: struct pcs_krpc objects are long-lived, and a
> patched kernel would dereference the new member on objects allocated
> before the livepatch was loaded, reading unallocated slab space.
>
> Both things connect_req was tracking are already derivable from the
> existing state machine once PCS_KRPC_STATE_CONNECT is made to mean
> exactly "a connect req is in flight":
>
> - krpc_connect_done() settles a failed connect back to UNCONN instead
> of leaving the state in CONNECT forever;
>
> - pcs_krpc_abort() no longer resets CONNECT to UNCONN: the req is
> still in flight, and only its completion settles the state. It
> advances gen instead, disowning the pending req: when the req
> completes, krpc_connect_done() settles the state to UNCONN without
> committing the dead session, even if the late connect succeeded;
>
> - pcs_krpc_connect() proceeds only from UNCONN or ABORTED, refusing
> new connects (-EPERM) while a req is in flight - at most one connect
> req exists at a time, same as with the connect_req check;
>
> - pcs_krpc_poll() reports EPOLLERR on UNCONN: poll bails out earlier
> unless ctx->gen == krpc->gen, and the current session can only be in
> UNCONN if its connect failed, which is what the (CONNECT && !connect_req)
> test used to detect.
- pcs_krpc_poll() reports EPOLLERR on UNCONN, and the gen check moves
under krpc->lock into the same condition: with ctx->gen == krpc->gen
the current session can only be in UNCONN if its connect failed,
which is what the (CONNECT && !connect_req) test used to detect.
> Within CONNECT the pending req carries the current gen unless the
> session was aborted, so a gen mismatch in krpc_connect_done() reliably
> identifies a disowned req.
>
Fixes: 7ae23fa1c145e ("fs/fuse kio: fix kRPC connect issues")
Feature: fuse: kRPC - single RPC for kernel and userspace
> https://virtuozzo.atlassian.net/browse/VSTOR-135626
>
> Signed-off-by: Liu Kui <kui.liu at virtuozzo.com>
Reviewed-by: Konstantin Khorenko <khorenko at virtuozzo.com>
--
Konstantin Khorenko <khorenko at virtuozzo.com>
More information about the Devel
mailing list