ia64/xen-unstable
changeset 11427:3f568dd6bda6
[XEN] Add more checking when reusing an active grant reference.
Signed-off-by: Steven Smith <sos22@cam.ac.uk>
Based-on-a-patch-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Steven Smith <sos22@cam.ac.uk>
Based-on-a-patch-by: Herbert Xu <herbert@gondor.apana.org.au>
author | ssmith@weybridge.uk.xensource.com |
---|---|
date | Tue Sep 05 14:27:05 2006 +0100 (2006-09-05) |
parents | ba39c2da5e84 |
children | 45746c770018 |
files | xen/common/grant_table.c |
line diff
1.1 --- a/xen/common/grant_table.c Tue Sep 05 13:57:30 2006 +0100 1.2 +++ b/xen/common/grant_table.c Tue Sep 05 14:27:05 2006 +0100 1.3 @@ -175,12 +175,13 @@ static void 1.4 1.5 spin_lock(&rd->grant_table->lock); 1.6 1.7 + sdom = sha->domid; 1.8 + 1.9 if ( !act->pin || 1.10 (!(op->flags & GNTMAP_readonly) && 1.11 !(act->pin & (GNTPIN_hstw_mask|GNTPIN_devw_mask))) ) 1.12 { 1.13 sflags = sha->flags; 1.14 - sdom = sha->domid; 1.15 1.16 /* 1.17 * This loop attempts to set the access (reading/writing) flags 1.18 @@ -235,6 +236,10 @@ static void 1.19 act->frame = gmfn_to_mfn(rd, sha->frame); 1.20 } 1.21 } 1.22 + else if ( unlikely(sdom != ld->domain_id) ) 1.23 + PIN_FAIL(unlock_out, GNTST_general_error, 1.24 + "Bad domain (%d). (NB. expected dom %d)\n", 1.25 + sdom, ld->domain_id); 1.26 else if ( (act->pin & 0x80808080U) != 0 ) 1.27 PIN_FAIL(unlock_out, ENOSPC, 1.28 "Risk of counter overflow %08x\n", act->pin); 1.29 @@ -771,11 +776,12 @@ static int 1.30 1.31 spin_lock(&rd->grant_table->lock); 1.32 1.33 + sdom = sha->domid; 1.34 + 1.35 if ( !act->pin || 1.36 (!readonly && !(act->pin & GNTPIN_hstw_mask)) ) 1.37 { 1.38 sflags = sha->flags; 1.39 - sdom = sha->domid; 1.40 1.41 for ( ; ; ) 1.42 { 1.43 @@ -819,6 +825,10 @@ static int 1.44 act->frame = gmfn_to_mfn(rd, sha->frame); 1.45 } 1.46 } 1.47 + else if ( unlikely(sdom != current->domain->domain_id) ) 1.48 + PIN_FAIL(unlock_out, GNTST_general_error, 1.49 + "Bad domain (%d). (NB. expected dom %d)\n", 1.50 + sdom, current->domain->domain_id); 1.51 else if ( (act->pin & 0x80808080U) != 0 ) 1.52 PIN_FAIL(unlock_out, ENOSPC, 1.53 "Risk of counter overflow %08x\n", act->pin);