All of lore.kernel.org
 help / color / mirror / Atom feed
* Fix for SSP error in tools/python/lowlevel/xc/xc.c
@ 2009-08-26 14:19 Milan Holzäpfel
  2009-08-26 17:39 ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 5+ messages in thread
From: Milan Holzäpfel @ 2009-08-26 14:19 UTC (permalink / raw)
  To: xen-devel; +Cc: mail


[-- Attachment #1.1.1: Type: text/plain, Size: 1326 bytes --]

Hello, 

I compiled xen-tools with GCC-4.3.3 with Stack Smashing Protection
(SSP) patches by gentoo, and found a small bug in
tools/python/lowlevel/xc/xc.c.  The bug is located in
pyxc_dom_set_policy_cpuid: 

(this is the change which fixes it:)

> @@ -808,7 +808,7 @@
>  static PyObject *pyxc_dom_set_policy_cpuid(XcObject *self,
>                                             PyObject *args)
>  {
> -    domid_t domid;
> +    int domid;
>  
>      if ( !PyArg_ParseTuple(args, "i", &domid) )
>          return NULL;

domid_t is defined as uint16_t (thus 2 bytes long) in xen header files,
but the "i" format needs a C "int" type, which is 4 bytes long.
(<URL:http://docs.python.org/c-api/arg.html>)  This error is detected
by SSP as stack overflow. 

Attached patch fixes the error.  Maybe it would better to use "h"
format instead of the "i" format, which converts the argument to an C
"short int".  Then you would have to change the python wrapper if
domid_t changes, though. 

Please apply this patch or the change to the "h" format string (I
haven't tested it, but I believe it should work just as well). 

Regards,
Milan Holzäpfel


-- 
Milan Holzaepfel <mail(a)mjh(d)name>             <URL:http://mjh.name/>
pub  4096R/C790FC23  EB8E 5E81 81E3 53A9 9B74  B895 5179 54C0 C790 FC23

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: xen-3.4.1_fix_ssp_error.diff --]
[-- Type: text/x-patch; name="xen-3.4.1_fix_ssp_error.diff", Size: 672 bytes --]

	2009-08-26 Milan Holzaepfel <mail@mjh.name>

	As documented on <URL:http://docs.python.org/c-api/arg.html>, the "i"
	format string needs an integer as target.

	Error detected by gentoo Stack Smashing Protection for gcc-4.3.3.

--- xen-3.4.1/tools/python/xen/lowlevel/xc/xc.c.orig	2009-08-26 13:43:13.000000000 +0000
+++ xen-3.4.1/tools/python/xen/lowlevel/xc/xc.c	2009-08-26 13:43:20.000000000 +0000
@@ -808,7 +808,7 @@
 static PyObject *pyxc_dom_set_policy_cpuid(XcObject *self,
                                            PyObject *args)
 {
-    domid_t domid;
+    int domid;
 
     if ( !PyArg_ParseTuple(args, "i", &domid) )
         return NULL;

[-- Attachment #1.2: Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

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

end of thread, other threads:[~2009-08-27 16:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-26 14:19 Fix for SSP error in tools/python/lowlevel/xc/xc.c Milan Holzäpfel
2009-08-26 17:39 ` Konrad Rzeszutek Wilk
2009-08-27  8:36   ` Milan Holzäpfel
2009-08-27 12:23     ` Konrad Rzeszutek Wilk
2009-08-27 16:27       ` Milan Holzäpfel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.