Skip to contentSkip to conversation

9p/xen: do not memcpy header into req->rc

PATCH In review Dominique Martinet 3 participants 3 messages Nov 22, 2022 9P file system

lore
Share & tools
lore

Dominique Martinet

author maintainer
#0 lore raw

PATCH 1/1 9p/xen: do not memcpy header into req->rc

while 'h' is packed and can be assumed to match the request payload, req->rc is a struct p9_fcall which is not packed and that memcpy could be wrong.

Fix this by copying each fields individually instead.

---
Follow up from the previous xen patch's review.

This isn't an immediate fix so I don't think this one should be rushed in with the rest of the overflow fixes -- I'll let this sit a bit in -next after reviews.

 net/9p/trans_xen.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/9p/trans_xen.c +3 -1
index 4665215bc98b..e8e3f54a837e 100644
@@ -216,7 +216,9 @@ static void p9_xen_response(struct work_struct *work)
 			goto recv_error;
 		}
 
-		memcpy(&req->rc, &h, sizeof(h));
+		req->rc.size = h.size;
+		req->rc.id = h.id;
+		req->rc.tag = h.tag;
 		req->rc.offset = 0;
 
 		masked_cons = xen_9pfs_mask(cons, XEN_9PFS_RING_SIZE(ring));
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Dominique Martinet

while 'h' is packed and can be assumed to match the request payload, req->rc is a struct p9_fcall which is not packed and that memcpy could be wrong.

Fix this by copying each fields individually instead.

Quoted 28 lines

---
Follow up from the previous xen patch's review.

This isn't an immediate fix so I don't think this one should be rushed in with the rest of the overflow fixes -- I'll let this sit a bit in

(quoted diff) +0 -1
-next after reviews.
 
 net/9p/trans_xen.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/9p/trans_xen.c +3 -1
index 4665215bc98b..e8e3f54a837e 100644
@@ -216,7 +216,9 @@ static void p9_xen_response(struct work_struct *work)
 			goto recv_error;
 		}
 
-		memcpy(&req->rc, &h, sizeof(h));
+		req->rc.size = h.size;
+		req->rc.id = h.id;
+		req->rc.tag = h.tag;
 		req->rc.offset = 0;
 
 		masked_cons = xen_9pfs_mask(cons, XEN_9PFS_RING_SIZE(ring));
Signature · 1 line
2.35.1
reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Dominique Martinet
Quoted 11 lines · CET Dominique Martinet

while 'h' is packed and can be assumed to match the request payload, req->rc is a struct p9_fcall which is not packed and that memcpy could be wrong.

Fix this by copying each fields individually instead.

---

Quoted 25 lines

Follow up from the previous xen patch's review.

This isn't an immediate fix so I don't think this one should be rushed in with the rest of the overflow fixes -- I'll let this sit a bit in

(quoted diff) +0 -1
-next after reviews.
 
 net/9p/trans_xen.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/9p/trans_xen.c +3 -1
index 4665215bc98b..e8e3f54a837e 100644
@@ -216,7 +216,9 @@ static void p9_xen_response(struct work_struct *work)
 			goto recv_error;
 		}
 
-		memcpy(&req->rc, &h, sizeof(h));
+		req->rc.size = h.size;
+		req->rc.id = h.id;
+		req->rc.tag = h.tag;
 		req->rc.offset = 0;
 
 		masked_cons = xen_9pfs_mask(cons, XEN_9PFS_RING_SIZE(ring));