]> git.proxmox.com Git - pve-qemu-kvm.git/blob - debian/patches/extra/CVE-2016-2197-ahci-null-pointer.patch
1a3da448ef8b39f91fd54934f996100042da913e
[pve-qemu-kvm.git] / debian / patches / extra / CVE-2016-2197-ahci-null-pointer.patch
1 From 867dcfc8c153c463090b972c2afc7b90700bab91 Mon Sep 17 00:00:00 2001
2 From: Prasad J Pandit <pjp@fedoraproject.org>
3 Date: Fri, 29 Jan 2016 01:18:50 +0530
4 Subject: [PATCH 2/2] ide: ahci: add check before calling dma_memory_unmap
5
6 When IDE AHCI emulation uses Frame Information Structures(FIS)
7 engine for data transfer, the mapped FIS buffer address is stored
8 in a static 'bounce.buffer'. When a request is made to map another
9 memory region, address_space_map() returns NULL because
10 'bounce.buffer' is in_use. It leads to a null pointer dereference
11 error while doing 'dma_memory_unmap'. Add a check to avoid it.
12
13 Reported-by: Zuozhi fzz <zuozhi.fzz@alibaba-inc.com>
14 Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
15 ---
16 hw/ide/ahci.c | 16 ++++++++++------
17 1 file changed, 10 insertions(+), 6 deletions(-)
18
19 diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
20 index dd1912e..ea351fe 100644
21 --- a/hw/ide/ahci.c
22 +++ b/hw/ide/ahci.c
23 @@ -661,9 +661,11 @@ static bool ahci_map_fis_address(AHCIDevice *ad)
24
25 static void ahci_unmap_fis_address(AHCIDevice *ad)
26 {
27 - dma_memory_unmap(ad->hba->as, ad->res_fis, 256,
28 - DMA_DIRECTION_FROM_DEVICE, 256);
29 - ad->res_fis = NULL;
30 + if (ad->res_fis) {
31 + dma_memory_unmap(ad->hba->as, ad->res_fis, 256,
32 + DMA_DIRECTION_FROM_DEVICE, 256);
33 + ad->res_fis = NULL;
34 + }
35 }
36
37 static bool ahci_map_clb_address(AHCIDevice *ad)
38 @@ -677,9 +679,11 @@ static bool ahci_map_clb_address(AHCIDevice *ad)
39
40 static void ahci_unmap_clb_address(AHCIDevice *ad)
41 {
42 - dma_memory_unmap(ad->hba->as, ad->lst, 1024,
43 - DMA_DIRECTION_FROM_DEVICE, 1024);
44 - ad->lst = NULL;
45 + if (ad->lst) {
46 + dma_memory_unmap(ad->hba->as, ad->lst, 1024,
47 + DMA_DIRECTION_FROM_DEVICE, 1024);
48 + ad->lst = NULL;
49 + }
50 }
51
52 static void ahci_write_fis_sdb(AHCIState *s, NCQTransferState *ncq_tfs)
53 --
54 2.1.4
55