Skip to contentSkip to conversation

tools/libxc: Don't leak foreign mappings when loading modules

PATCH In review Andrew Cooper 3 participants 5 messages Sep 30, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 tools/libxc: Don't leak foreign mappings when loading modules

Spotted by Coverity

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Boris Ostrovsky <[email protected]>

---
 tools/libxc/xc_dom_core.c | 1 +
 1 file changed, 1 insertion(+)
tools/libxc/xc_dom_core.c +1 -0
index 5326d36..e177667 100644
@@ -1119,6 +1119,7 @@ static int xc_dom_load_acpi(struct xc_dom_image *dom)
         }
 
         memcpy(ptr, dom->acpi_modules[i].data, dom->acpi_modules[i].length);
+        munmap(ptr, XC_PAGE_SIZE * num_pages);
 
         free(extents);
         i++;
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw

PATCH 2/2 x86/emulate: Resolve MISSING_BREAK issue in x86_decode()

Coverity doesn't appear to be able to spot that this is a terminal error path, but leave a comment to "fix" MISSING_BREAK.

---
CC: Jan Beulich <[email protected]>

This issue is newly exposed since splitting x86_decode() away from x86_emulate(). I seem to recall that Coverity has an upper bound of paths-per-function which it will tolerate (to avoid infinite loops), and the split allows double the exploration space.

---
 xen/arch/x86/x86_emulate/x86_emulate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/x86_emulate/x86_emulate.c +1 -1
index 78b23a0..32e8b69 100644
@@ -1891,7 +1891,7 @@ x86_decode(
             switch ( def_ad_bytes )
             {
             default:
-                BUG();
+                BUG(); /* Shouldn't be possible. */
             case 2:
                 if ( in_realmode(ctxt, ops) || (state->regs->eflags & EFLG_VM) )
                     break;
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] x86/emulate: Resolve MISSING_BREAK issue in x86_decode()

Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 30.09.16 at 12:01, <[email protected]> wrote:

Coverity doesn't appear to be able to spot that this is a terminal error path, but leave a comment to "fix" MISSING_BREAK.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw

Re: [PATCH 2/2] x86/emulate: Resolve MISSING_BREAK issue in x86_decode()

Quoted 8 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 30.09.16 at 12:01, <[email protected]> wrote:

Coverity doesn't appear to be able to spot that this is a terminal error path, but leave a comment to "fix" MISSING_BREAK.

Series pushed.

Quoted 5 lines

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Acked-by on v1 1/2
#4 lore raw
In reply to Andrew Cooper
Quoted 3 lines · Andrew Cooper

Spotted by Coverity

Quoted 23 lines

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Boris Ostrovsky <[email protected]>

---
 tools/libxc/xc_dom_core.c | 1 +
 1 file changed, 1 insertion(+)
tools/libxc/xc_dom_core.c +1 -0
index 5326d36..e177667 100644
@@ -1119,6 +1119,7 @@ static int xc_dom_load_acpi(struct xc_dom_image *dom)
         }
 
         memcpy(ptr, dom->acpi_modules[i].data, dom->acpi_modules[i].length);
+        munmap(ptr, XC_PAGE_SIZE * num_pages);
 
         free(extents);
         i++;
Signature · 1 line
2.1.4

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel