Skip to content

Commit 14995c4

Browse files
Raphael Zimmergregkh
authored andcommitted
rbd: Reset positive result codes to zero in object map update path
commit a6c4250 upstream. In a reply message to an RBD request, a positive result code indicates a data payload, which is not allowed for writes. While rbd_osd_req_callback() already resets a positive result code for writes to zero, rbd_object_map_callback() does not. This allows a corrupted reply to an object map update to trigger the rbd_assert(*result < 0) in __rbd_obj_handle_request(). This happens, because rbd_object_map_callback() calls rbd_obj_handle_request() -> __rbd_obj_handle_request() and passes this positive result code. From __rbd_obj_handle_request(), rbd_obj_advance_write() is called, which leaves the positive result code unchanged and returns true. Therefore, the if(done && *result) branch is executed in __rbd_obj_handle_request() and the assertion triggers. This patch fixes the issue by adjusting the logic in the rbd_object_map_callback() path. A positive result code for an object map update is now reset to zero (similar to rbd_osd_req_callback()), and the message is subsequently handled the same way as if the result code was zero from the beginning. Additionally, a WARN_ON_ONCE() is added for this case. Cc: stable@vger.kernel.org Fixes: 22e8bd5 ("rbd: support for object-map and fast-diff") Signed-off-by: Raphael Zimmer <raphael.zimmer@tu-ilmenau.de> Reviewed-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c674751 commit 14995c4

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

drivers/block/rbd.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1957,9 +1957,14 @@ static int rbd_object_map_update_finish(struct rbd_obj_request *obj_req,
19571957
bool has_current_state;
19581958
void *p;
19591959

1960-
if (osd_req->r_result)
1960+
if (osd_req->r_result < 0)
19611961
return osd_req->r_result;
19621962

1963+
/*
1964+
* Writes aren't allowed to return a data payload.
1965+
*/
1966+
WARN_ON_ONCE(osd_req->r_result > 0);
1967+
19631968
/*
19641969
* Nothing to do for a snapshot object map.
19651970
*/

0 commit comments

Comments
 (0)