Argument handling bugs in XSM:FLASK
PATCH 1/1 Argument handling bugs in XSM:FLASK
The attached patch addresses a number of argument handling bugs in the flask_op hypercall in the XSM:Flask module. Thanks to Rafal Wojtczuk at McAfee for reporting the issues and Tim Deegan at Citrix for providing an initial patch.
This patch addresses the following issues:
- bounds checking and validation on input arguments to flask_op
- updated ABI/API, size and cmd are now uint32_t
- updated userspace tools and libraries to account for ABI/API changes
- implemented all copies using from/to guest, better portability
- implemented upper bounds checking on op->cmd, op->size
- implemented sanity checking on op->size and op->buf
- implemented bit vector for checking from/to usage on op->cmd
Please do not hesitate to contact me on future issues/concerns/comments related to XSM and the Flask module.
<Signed-off-by: George Coker, [email protected]>
Signature · 1 line
George S. Coker, II <[email protected]>
tools/flask/libflask/flask_op.c +3 -3
@@ -22,7 +22,7 @@#include <flask.h> #include <xenctrl.h> -int flask_load (int xc_handle,char *buf,int size) +int flask_load (int xc_handle,char *buf,uint32_t size) {int err;flask_op_t op;
@@ -37,7 +37,7 @@ int flask_load(int xc_handle, char *buf,return 0 ; } -int flask_context_to_sid (int xc_handle,char *buf,int size,uint32_t *sid) +int flask_context_to_sid (int xc_handle,char *buf,uint32_t size,uint32_t *sid) {int err;flask_op_t op;
@@ -54,7 +54,7 @@ int flask_context_to_sid(int xc_handle,return 0 ; } -int flask_sid_to_context (int xc_handle,int sid,char *buf,int size) +int flask_sid_to_context (int xc_handle,int sid,char *buf,uint32_t size) {int err;flask_op_t op;
tools/flask/libflask/include/flask.h +3 -3
@@ -15,8 +15,8 @@#include <xen/xen.h> #include <xen/xsm/flask_op.h> -int flask_load (int xc_handle,char *buf,int size); -int flask_context_to_sid (int xc_handle,char *buf,int size,uint32_t *sid); -int flask_sid_to_context (int xc_handle,int sid,char *buf,int size); +int flask_load (int xc_handle,char *buf,uint32_t size); +int flask_context_to_sid (int xc_handle,char *buf,uint32_t size,uint32_t *sid); +int flask_sid_to_context (int xc_handle,int sid,char *buf,uint32_t size);#endif /* __FLASK_H__ */
xen/include/public/xsm/flask_op.h +5 -3
@@ -32,10 +32,12 @@#define FLASK_AVC_CACHESTATS 19#define FLASK_MEMBER 20 +#define FLASK_LAST FLASK_MEMBER +typedef struct flask_op { -int cmd; -int size; -char *buf; +uint32_t cmd; +uint32_t size; +char *buf; }flask_op_t ;DEFINE_XEN_GUEST_HANDLE (flask_op_t);
xen/xsm/flask/avc.c +2 -2
@@ -250,7 +250,7 @@ void __init avc_init(void)printk ("AVC INITIALIZED\n" ); } -int avc_get_hash_stats (char *page) +int avc_get_hash_stats (char *buf,uint32_t size) {int i, chain_len, max_chain_len, slots_used;struct avc_node *node;
@@ -274,7 +274,7 @@ int avc_get_hash_stats(char *page)rcu_read_unlock (); -return snprintf (page,PAGE_SIZE ,"entries: %d\nbuckets used: %d/%d\n" +return snprintf (buf, size,"entries: %d\nbuckets used: %d/%d\n" "longest chain: %d\n" ,atomic_read (&avc_cache.active_nodes), slots_used,AVC_CACHE_SLOTS , max_chain_len);
xen/xsm/flask/flask_op.c +256 -396
1,011 lines not on this page · raw message
xen/xsm/flask/include/avc.h +1 -1
@@ -95,7 +95,7 @@ int avc_add_callback(int (*callback)(u32 u32 ssid, u32 tsid, u16 tclass, u32 perms);/* Exported to selinuxfs */ -int avc_get_hash_stats (char *page); +int avc_get_hash_stats (char *buf,uint32_t size);extern unsigned int avc_cache_threshold;#ifdef FLASK_AVC_STATS
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel