xen: mark pvscsi frontend request consumed only after last read
Juergen Gross
maintainerPATCH 1/1 xen: mark pvscsi frontend request consumed only after last read
A request in the ring buffer mustn't be read after it has been marked as consumed. Otherwise it might already have been reused by the frontend without violating the ring protocol.
To avoid inconsistencies in the backend only work on a private copy of the request. This will ensure a malicious guest not being able to bypass consistency checks of the backend by modifying an active request.
drivers/xen/scsiback/scsiback.c +3 -3
@@ -579,7 +579,7 @@ invalid_value:static int _scsiback_do_cmd_fn (struct vscsibk_info *info) {struct vscsiif_back_ring *ring = &info->ring; -vscsiif_request_t *ring_req; +vscsiif_request_t ring_req;pending_req_t *pending_req;RING_IDX rc, rp;
@@ -609,10 +609,10 @@ static int _scsiback_do_cmd_fn(struct vsbreak ; } - ring_req =RING_GET_REQUEST (ring, rc); + ring_req = *RING_GET_REQUEST (ring, rc); ring->req_cons = ++rc; - err =prepare_pending_reqs (info, ring_req, + err =prepare_pending_reqs (info, &ring_req, pending_req);switch (err ?: pending_req->act) {case VSCSIIF_ACT_SCSI_CDB :
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 30.01.15 at 14:51, <"[email protected]".non-mime.internet> wrote:
A request in the ring buffer mustn't be read after it has been marked as consumed. Otherwise it might already have been reused by the frontend without violating the ring protocol.
To avoid inconsistencies in the backend only work on a private copy of the request. This will ensure a malicious guest not being able to bypass consistency checks of the backend by modifying an active request.
I'm not convinced we need this in this version of the driver: c/s 590:c4134d1a3e3f took care of reading each ring_req field just once.
Jan
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines · On 30.01.15 at 15:22, <[email protected]> wrote:
Quoted 1 line · On 30.01.15 at 14:51, <"[email protected]".non-mime.internet> wrote:
A request in the ring buffer mustn't be read after it has been marked as consumed. Otherwise it might already have been reused by the frontend without violating the ring protocol.
Quoted 8 lines
Quoted 4 lines
To avoid inconsistencies in the backend only work on a private copy of the request. This will ensure a malicious guest not being able to bypass consistency checks of the backend by modifying an active request.
I'm not convinced we need this in this version of the driver: c/s 590:c4134d1a3e3f took care of reading each
ring_reqfield just once.
I should have clarified that I didn't mean we don't need to change anything here: We should still move down the point where the ring slot gets accounted as consumed.
Jan
A message that is not in the archive (sent off-list or not yet received): [email protected]
Juergen Gross
maintainerQuoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 10 lines
Quoted 2 lines · On 30.01.15 at 15:22, <[email protected]> wrote:
Quoted 1 line · On 30.01.15 at 14:51, <"[email protected]".non-mime.internet> wrote:
A request in the ring buffer mustn't be read after it has been marked as consumed. Otherwise it might already have been reused by the frontend without violating the ring protocol.
To avoid inconsistencies in the backend only work on a private copy of the request. This will ensure a malicious guest not being able to bypass consistency checks of the backend by modifying an active request.
Quoted 7 lines
Quoted 3 lines
I'm not convinced we need this in this version of the driver: c/s 590:c4134d1a3e3f took care of reading each
ring_reqfield just once.I should have clarified that I didn't mean we don't need to change anything here: We should still move down the point where the ring slot gets accounted as consumed.
My solution is more robust, I think. You don't have to be careful not to introduce another double read somewhere.
Juergen
A message that is not in the archive (sent off-list or not yet received): [email protected]
Juergen Gross
maintainerQuoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 30.01.15 at 14:51, <"[email protected]".non-mime.internet> wrote:
A request in the ring buffer mustn't be read after it has been marked as consumed. Otherwise it might already have been reused by the frontend without violating the ring protocol.
Quoted 8 lines
Quoted 4 lines
To avoid inconsistencies in the backend only work on a private copy of the request. This will ensure a malicious guest not being able to bypass consistency checks of the backend by modifying an active request.
I'm not convinced we need this in this version of the driver: c/s 590:c4134d1a3e3f took care of reading each
ring_reqfield just once.
This might be true. But the consumer index is incremented before the last item of the request is read. This is a violation of the ring
interface: the frontend is free to put another request in this slot while the backend is still using it.
Juergen
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 30.01.15 at 14:51, <"[email protected]".non-mime.internet> wrote:
A request in the ring buffer mustn't be read after it has been marked as consumed. Otherwise it might already have been reused by the frontend without violating the ring protocol.
This is irrelevant, as the ->req_cons is a backend private field (if it was a shared one, a barrier would have been needed between copying and updating that field).
Quoted 4 lines
To avoid inconsistencies in the backend only work on a private copy of the request. This will ensure a malicious guest not being able to bypass consistency checks of the backend by modifying an active request.
Hence - also considering with my earlier reply - I don't view the change as necessary.
Jan
Juergen Gross
maintainerQuoted 8 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 30.01.15 at 14:51, <"[email protected]".non-mime.internet> wrote:
A request in the ring buffer mustn't be read after it has been marked as consumed. Otherwise it might already have been reused by the frontend without violating the ring protocol.
This is irrelevant, as the ->req_cons is a backend private field (if it was a shared one, a barrier would have been needed between copying and updating that field).
Hmm, you are right. Interesting, I've always thought req_cons would be used by the frontend, too.
Thanks for updating my protocol know-how. :-)
Quoted 8 lines
Quoted 5 lines
To avoid inconsistencies in the backend only work on a private copy of the request. This will ensure a malicious guest not being able to bypass consistency checks of the backend by modifying an active request.
Hence - also considering with my earlier reply - I don't view the change as necessary.
Agreed.
Juergen