xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] x86/mm: Avoid NULL dereference when checking altp2m's for shareability
@ 2016-07-27 18:08 Andrew Cooper
  2016-07-27 18:08 ` [PATCH 2/2] x86/mm: Annotate gfn_get_* helpers as requiring non-NULL parameters Andrew Cooper
  2016-07-28 15:51 ` [PATCH 1/2] x86/mm: Avoid NULL dereference when checking altp2m's for shareability George Dunlap
  0 siblings, 2 replies; 10+ messages in thread
From: Andrew Cooper @ 2016-07-27 18:08 UTC (permalink / raw)
  To: Xen-devel
  Cc: George Dunlap, Andrew Cooper, Tim Deegan, Jan Beulich,
	Tamas K Lengyel

Coverity identifies that __get_gfn_type_access() unconditionally writes to its
type parameter under a number of circumstances.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Tim Deegan <tim@xen.org>
CC: George Dunlap <george.dunlap@eu.citrix.com>
CC: Tamas K Lengyel <tamas.lengyel@zentific.com>

There is a second complaint that ap2ma and p2ma are used before initialisation
in the following line, although that is harder to reason about.  I think the
code is OK...
---
 xen/arch/x86/mm/mem_sharing.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c
index 47e0820..14952ce 100644
--- a/xen/arch/x86/mm/mem_sharing.c
+++ b/xen/arch/x86/mm/mem_sharing.c
@@ -870,6 +870,7 @@ int mem_sharing_nominate_page(struct domain *d,
         unsigned int i;
         struct p2m_domain *ap2m;
         mfn_t amfn;
+        p2m_type_t ap2mt;
         p2m_access_t ap2ma;
 
         altp2m_list_lock(d);
@@ -880,7 +881,7 @@ int mem_sharing_nominate_page(struct domain *d,
             if ( !ap2m )
                 continue;
 
-            amfn = get_gfn_type_access(ap2m, gfn, NULL, &ap2ma, 0, NULL);
+            amfn = get_gfn_type_access(ap2m, gfn, &ap2mt, &ap2ma, 0, NULL);
             if ( mfn_valid(amfn) && (mfn_x(amfn) != mfn_x(mfn) || ap2ma != p2ma) )
             {
                 altp2m_list_unlock(d);
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-08-02 13:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-27 18:08 [PATCH 1/2] x86/mm: Avoid NULL dereference when checking altp2m's for shareability Andrew Cooper
2016-07-27 18:08 ` [PATCH 2/2] x86/mm: Annotate gfn_get_* helpers as requiring non-NULL parameters Andrew Cooper
2016-07-28 15:58   ` George Dunlap
2016-07-28 16:11     ` Andrew Cooper
2016-08-01 15:38     ` Jan Beulich
2016-08-01 16:59     ` [PATCH v2 " Andrew Cooper
2016-08-02  7:18       ` Jan Beulich
2016-08-02 13:14       ` George Dunlap
2016-08-01 15:40   ` [PATCH " Jan Beulich
2016-07-28 15:51 ` [PATCH 1/2] x86/mm: Avoid NULL dereference when checking altp2m's for shareability George Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).