[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[qemu-xen master] hw/nvme: fix buffer overrun in nvme_changed_nslist (CVE-2021-3947)



commit 2b2eb343a01bb84a9d988158f706a65b57604d65
Author:     Klaus Jensen <k.jensen@xxxxxxxxxxx>
AuthorDate: Wed Nov 17 14:12:56 2021 +0100
Commit:     Michael Roth <michael.roth@xxxxxxx>
CommitDate: Tue Dec 14 14:52:50 2021 -0600

    hw/nvme: fix buffer overrun in nvme_changed_nslist (CVE-2021-3947)
    
    Fix missing offset verification.
    
    Cc: qemu-stable@xxxxxxxxxx
    Cc: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
    Reported-by: Qiuhao Li <Qiuhao.Li@xxxxxxxxxxx>
    Fixes: f432fdfa121 ("support changed namespace asynchronous event")
    Reviewed-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
    Signed-off-by: Klaus Jensen <k.jensen@xxxxxxxxxxx>
    (cherry picked from commit e2c57529c9306e4c9aac75d9879f6e7699584a22)
    Signed-off-by: Michael Roth <michael.roth@xxxxxxx>
---
 hw/nvme/ctrl.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index 6baf9e0420..27dddb87bd 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -4164,6 +4164,11 @@ static uint16_t nvme_changed_nslist(NvmeCtrl *n, uint8_t 
rae, uint32_t buf_len,
     int i = 0;
     uint32_t nsid;
 
+    if (off >= sizeof(nslist)) {
+        trace_pci_nvme_err_invalid_log_page_offset(off, sizeof(nslist));
+        return NVME_INVALID_FIELD | NVME_DNR;
+    }
+
     memset(nslist, 0x0, sizeof(nslist));
     trans_len = MIN(sizeof(nslist) - off, buf_len);
 
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.