The commit is pushed to "branch-rh9-5.14.0-427.44.1.vz9.80.x-ovz" and will 
appear at g...@bitbucket.org:openvz/vzkernel.git
after rh9-5.14.0-427.44.1.vz9.80.23
------>
commit f1b3519cb9cb2dcac93a92d9ae362cfdd740f4d2
Author: Alexey Kuznetsov <kuz...@virtuozzo.com>
Date:   Fri Mar 28 20:01:13 2025 +0800

    fs/fuse/krpc: prevent krpc request from crossing reconnect
    
    Do it with already existing generation id. kreq stores genid
    of connection at time of enqueue, and if it races with reconnect,
    it is rejected.
    
    Signed-off-by: Alexey Kuznetsov <kuz...@virtuozzo.com>
    
    Feature: fuse: kRPC - single RPC for kernel and userspace
---
 fs/fuse/kio/pcs/pcs_krpc.c | 5 ++++-
 fs/fuse/kio/pcs/pcs_krpc.h | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/fuse/kio/pcs/pcs_krpc.c b/fs/fuse/kio/pcs/pcs_krpc.c
index 58a9ceebfee2..28c6104d7dc3 100644
--- a/fs/fuse/kio/pcs/pcs_krpc.c
+++ b/fs/fuse/kio/pcs/pcs_krpc.c
@@ -581,7 +581,8 @@ static int kreq_make_sendmsg(struct krpc_req *kreq)
        msg->get_iter = krpc_msg_get_data;
 
        spin_lock(&krpc->lock);
-       if (krpc->state != PCS_KRPC_STATE_CONNECTED) {
+       if (krpc->state != PCS_KRPC_STATE_CONNECTED ||
+           krpc->gen != kreq->gen) {
                spin_unlock(&krpc->lock);
                res = -ECONNABORTED;
                goto err_free_data_chunk;
@@ -826,6 +827,8 @@ static long pcs_krpc_ioctl(struct file *file, unsigned int 
cmd, unsigned long ar
                if (!kreq)
                        return -ENOMEM;
 
+               kreq->gen = ctx->gen;
+
                if (copy_from_user(&kreq->iocmsg, (void __user *)arg, 
sizeof(kreq->iocmsg))) {
                        krpc_req_free(kreq);
                        return -EFAULT;
diff --git a/fs/fuse/kio/pcs/pcs_krpc.h b/fs/fuse/kio/pcs/pcs_krpc.h
index 8021b0262560..15d9f77aa401 100644
--- a/fs/fuse/kio/pcs/pcs_krpc.h
+++ b/fs/fuse/kio/pcs/pcs_krpc.h
@@ -130,6 +130,7 @@ struct krpc_req {
 
        struct krpc_completion completion;
 
+       u32                         gen;
        struct llist_node           llist_link;
        struct pcs_krpc_ioc_sendmsg iocmsg;
 };
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to