[Devel] [PATCH RHEL9 COMMIT] fs/fuse kio: skip looking into response to request from userspace
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Aug 2 19:08:35 MSK 2024
The commit is pushed to "branch-rh9-5.14.0-427.26.1.vz9.66.x-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh9-5.14.0-427.26.1.vz9.66.1
------>
commit cc2baeef58036acdcada94bafa97eac7ad996d26
Author: Liu Kui <kui.liu at virtuozzo.com>
Date: Tue Jul 30 11:16:27 2024 +0700
fs/fuse kio: skip looking into response to request from userspace
Response to userspace requests should not be analyzed and translated
to msg->errors. Instead the entire response message should be just
passed to userspace and let userspace handle it.
Fix the issue that userspace krpcio getting aborted by PCS_RPC_ERROR_RESP
response.
Signed-off-by: Liu Kui <kui.liu at virtuozzo.com>
Acked-by: Alexey Kuznetsov <kuznet at virtuozzo.com>
Feature: fuse: kRPC - single RPC for kernel and userspace
---
fs/fuse/kio/pcs/pcs_krpc.c | 11 ++++++-----
fs/fuse/kio/pcs/pcs_krpc.h | 3 ++-
fs/fuse/kio/pcs/pcs_rpc.c | 7 +++++++
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/fs/fuse/kio/pcs/pcs_krpc.c b/fs/fuse/kio/pcs/pcs_krpc.c
index c08cdb07337b..f62bf6ef11aa 100644
--- a/fs/fuse/kio/pcs/pcs_krpc.c
+++ b/fs/fuse/kio/pcs/pcs_krpc.c
@@ -105,7 +105,8 @@ static void krpc_msg_get_response_iter(struct pcs_msg *msg, int offset,
struct pcs_msg *req = msg->private;
struct krpc_req *kreq = req->private2;
- if (!(kreq->flags & KRPC_REQ_F_RESP_BUFF)) {
+ if (!(kreq->flags & KRPC_REQ_F_RESP_BUFF) ||
+ (kreq->flags & KRPC_REQ_F_ERR_RESP)) {
/* No data payload */
BUG_ON(msg->size > PAGE_SIZE);
@@ -148,16 +149,16 @@ struct pcs_msg *krpc_get_hdr(struct pcs_rpc *ep, struct pcs_rpc_hdr *h)
if (msg == NULL)
return NULL;
- req_h = (struct pcs_rpc_hdr *)msg_inline_head(msg);
- if (req_h->type != (h->type & ~PCS_RPC_DIRECTION))
- return NULL;
-
kreq = msg->private2;
resp = pcs_rpc_alloc_input_msg(ep, sizeof(struct pcs_rpc_hdr));
if (!resp)
return NULL;
+ req_h = (struct pcs_rpc_hdr *)msg_inline_head(msg);
+ if (req_h->type != (h->type & ~PCS_RPC_DIRECTION))
+ kreq->flags |= KRPC_REQ_F_ERR_RESP;
+
memcpy(resp->_inline_buffer, h, sizeof(struct pcs_rpc_hdr));
memcpy(kreq->hdr_buf, h, sizeof(struct pcs_rpc_hdr));
resp->size = h->len;
diff --git a/fs/fuse/kio/pcs/pcs_krpc.h b/fs/fuse/kio/pcs/pcs_krpc.h
index 6c0ef20ebc99..8100dfb2629d 100644
--- a/fs/fuse/kio/pcs/pcs_krpc.h
+++ b/fs/fuse/kio/pcs/pcs_krpc.h
@@ -93,7 +93,8 @@ struct krpc_req {
#define KRPC_REQ_F_ALIGNMENT PCS_KRPC_MSG_F_ALIGNMENT
#define KRPC_REQ_F_RESP_BUFF PCS_KRPC_MSG_F_RESP_BUFF /* data buff is for read response */
-#define KRPC_REQ_F_ABORTED 0x10000
+#define KRPC_REQ_F_ABORTED 0x10000
+#define KRPC_REQ_F_ERR_RESP 0x20000
int flags;
struct pcs_msg msg;
diff --git a/fs/fuse/kio/pcs/pcs_rpc.c b/fs/fuse/kio/pcs/pcs_rpc.c
index 6b54a7bc7596..80bbffcb88a8 100644
--- a/fs/fuse/kio/pcs/pcs_rpc.c
+++ b/fs/fuse/kio/pcs/pcs_rpc.c
@@ -484,6 +484,12 @@ static void handle_response(struct pcs_rpc * ep, struct pcs_msg * msg)
pcs_msg_del_calendar(req);
list_del(&req->list);
+ /* don't try to interpret response to request from userspace */
+ if (!(h->xid.origin.val & PCS_NODE_ALT_MASK)) {
+ req->response = msg;
+ goto skip;
+ }
+
if (h->type == PCS_RPC_ERROR_RESP) {
struct pcs_rpc_error_resp * eh = (struct pcs_rpc_error_resp *)msg->_inline_buffer;
@@ -502,6 +508,7 @@ static void handle_response(struct pcs_rpc * ep, struct pcs_msg * msg)
req->response = msg;
}
+skip:
if (ep->ops->hook_response)
ep->ops->hook_response(ep, req);
More information about the Devel
mailing list