From: Jeremy Kerr Date: Mon, 3 Jul 2023 07:55:04 +0000 (+0800) Subject: mi: implement length and offset alignment checks in admin_xfer() X-Git-Tag: v1.6~69 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=ac95df01ce6c8b729095c36073e4d54c3d26bc5f;p=users%2Fsagi%2Flibnvme.git mi: implement length and offset alignment checks in admin_xfer() We're about to relax some alignment requirements in the generic (internal) nvme_mi_submit function. To ensure that the raw admin interface continues to enfore the required alignment on DOFST and DLEN fields, implement checks in the Admin command interface. Signed-off-by: Jeremy Kerr --- diff --git a/src/nvme/mi.c b/src/nvme/mi.c index 3799f35c..2d780674 100644 --- a/src/nvme/mi.c +++ b/src/nvme/mi.c @@ -580,8 +580,10 @@ int nvme_mi_admin_xfer(nvme_mi_ctrl_t ctrl, return -1; } - /* must be aligned */ - if (resp_data_offset & 0x3) { + /* request and response lengths & offset must be aligned */ + if ((req_data_size & 0x3) || + (*resp_data_size & 0x3) || + (resp_data_offset & 0x3)) { errno = EINVAL; return -1; }