]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
mi: implement length and offset alignment checks in admin_xfer()
authorJeremy Kerr <jk@codeconstruct.com.au>
Mon, 3 Jul 2023 07:55:04 +0000 (15:55 +0800)
committerDaniel Wagner <wagi@monom.org>
Thu, 20 Jul 2023 08:40:38 +0000 (10:40 +0200)
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 <jk@codeconstruct.com.au>
src/nvme/mi.c

index 3799f35cb3ad8bd890dd3b34dc4e67fbb17d8b6d..2d780674e96cc8b5d1843ff7de060a34252d19dd 100644 (file)
@@ -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;
        }