[Xcb] [PATCH proto 7/9] xselinux: add explicit padding for struc "ListItem"

Christian Linhart chris at demorecorder.com
Sun Sep 13 06:45:15 PDT 2015


This is needed so that subsequent list-items in a list are aligned
to 4 bytes which is necessary because ListItem contains 32-bit values
of types ATOM and CARD32. (Actually, only the final align-pad
is needed for that.)

The xserver makes sure that the length of both char-lists is a multiple of 4:
http://cgit.freedesktop.org/xorg/xserver/tree/Xext/xselinux_ext.c?id=xorg-server-1.17.99.901#n360

So, instead of a explicit padding we could add something like an assertion
or precondition that the fields "object_context_len" and "data_context_len"
have to be a multiple of 4.

Unfortunately I couldn't find a protocol specification of the xselinux
extension, to see whether the multiple of 4 is mandated by the protocol spec
or whether there should be align-pads. (and whether there should
be an align pad between "object_context" and "data_context"

Does anybody know where the spec for the xselinux protocol is?
There ought to be a spec somewhere for this because this is
security relevant.

Signed-off-by: Christian Linhart <chris at demorecorder.com>
---
 src/xselinux.xml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/xselinux.xml b/src/xselinux.xml
index 7751470..a97a146 100644
--- a/src/xselinux.xml
+++ b/src/xselinux.xml
@@ -107,17 +107,19 @@ <request name="GetWindowContext" opcode="7">
   <struct name="ListItem">
     <field type="ATOM" name="name" />
     <field type="CARD32" name="object_context_len" />
     <field type="CARD32" name="data_context_len" />
     <list type="char" name="object_context">
       <fieldref>object_context_len</fieldref>
     </list>
+    <pad align="4" />
     <list type="char" name="data_context">
       <fieldref>data_context_len</fieldref>
     </list>
+    <pad align="4" />
   </struct>
 
   <request name="SetPropertyCreateContext" opcode="8">
     <field type="CARD32" name="context_len" />
     <list type="char" name="context">
       <fieldref>context_len</fieldref>
     </list>
-- 
2.1.4



More information about the Xcb mailing list