From: Stefan Berger Subject: [PATCH] [ACM] Check boundary conditions Date: Sat, 21 Jul 2007 11:00:30 -0400 Message-ID: <1185030030.16726.1.camel@gsal-3.watson.ibm.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-BMaFJpurd4hUbgis3SWO" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel Cc: Keir Fraser , sailer@us.ibm.com List-Id: xen-devel@lists.xenproject.org --=-BMaFJpurd4hUbgis3SWO Content-Type: text/plain Content-Transfer-Encoding: 7bit Check boundary conditions of passed parameters before accessing an array with them. Signed-off-by: Stefan Berger --=-BMaFJpurd4hUbgis3SWO Content-Disposition: attachment; filename=acm_boundary_check.diff Content-Type: text/x-patch; name=acm_boundary_check.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit --- xen-unstable.hg/xen/acm/acm_simple_type_enforcement_hooks.c | 19 +++++++----- 1 file changed, 12 insertions(+), 7 deletions(-) Index: root/xen-unstable.hg/xen/acm/acm_simple_type_enforcement_hooks.c =================================================================== --- root.orig/xen-unstable.hg/xen/acm/acm_simple_type_enforcement_hooks.c +++ root/xen-unstable.hg/xen/acm/acm_simple_type_enforcement_hooks.c @@ -40,13 +40,18 @@ struct ste_binary_policy ste_bin_pol; static inline int have_common_type (ssidref_t ref1, ssidref_t ref2) { int i; - for( i = 0; i< ste_bin_pol.max_types; i++ ) - if ( ste_bin_pol.ssidrefs[ref1*ste_bin_pol.max_types + i] && - ste_bin_pol.ssidrefs[ref2*ste_bin_pol.max_types + i]) - { - printkd("%s: common type #%02x.\n", __func__, i); - return 1; - } + + if ( ref1 >= 0 && ref1 < ste_bin_pol.max_ssidrefs && + ref2 >= 0 && ref2 > ste_bin_pol.max_ssidrefs ) + { + for( i = 0; i< ste_bin_pol.max_types; i++ ) + if ( ste_bin_pol.ssidrefs[ref1*ste_bin_pol.max_types + i] && + ste_bin_pol.ssidrefs[ref2*ste_bin_pol.max_types + i]) + { + printkd("%s: common type #%02x.\n", __func__, i); + return 1; + } + } return 0; } --=-BMaFJpurd4hUbgis3SWO Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-BMaFJpurd4hUbgis3SWO--