/daten/src/linux-2.4.27-rsbac-v1.2.3/rsbac/adf/daz/dazuko_call.c

Go to the documentation of this file.
00001 /* Dazuko. Check parameters of XP calls before making real calls. 00002 Written by John Ogness <jogness@antivir.de> 00003 00004 Copyright (c) 2003 H+BEDV Datentechnik GmbH 00005 All rights reserved. 00006 00007 Redistribution and use in source and binary forms, with or without 00008 modification, are permitted provided that the following conditions 00009 are met: 00010 00011 1. Redistributions of source code must retain the above copyright notice, 00012 this list of conditions and the following disclaimer. 00013 00014 2. Redistributions in binary form must reproduce the above copyright notice, 00015 this list of conditions and the following disclaimer in the documentation 00016 and/or other materials provided with the distribution. 00017 00018 3. Neither the name of Dazuko nor the names of its contributors may be used 00019 to endorse or promote products derived from this software without specific 00020 prior written permission. 00021 00022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00023 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00024 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00025 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00026 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00027 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00028 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00029 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00030 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00031 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 POSSIBILITY OF SUCH DAMAGE. 00033 */ 00034 00035 #include "dazuko_platform.h" 00036 00037 #include "dazuko_call.h" 00038 #include "dazuko_xp.h" 00039 00040 00041 /* mutex */ 00042 00043 inline int call_xp_init_mutex(struct xp_mutex *mutex) 00044 { 00045 if (mutex == NULL) 00046 { 00047 xp_print("dazuko: xp_init_mutex(NULL)\n"); 00048 return -1; 00049 } 00050 00051 return xp_init_mutex(mutex); 00052 } 00053 00054 inline int call_xp_down(struct xp_mutex *mutex) 00055 { 00056 if (mutex == NULL) 00057 { 00058 xp_print("dazuko: warning: xp_down(NULL)\n"); 00059 return -1; 00060 } 00061 00062 return xp_down(mutex); 00063 } 00064 00065 inline int call_xp_up(struct xp_mutex *mutex) 00066 { 00067 if (mutex == NULL) 00068 { 00069 xp_print("dazuko: warning: xp_up(NULL)\n"); 00070 return -1; 00071 } 00072 00073 return xp_up(mutex); 00074 } 00075 00076 inline int call_xp_destroy_mutex(struct xp_mutex *mutex) 00077 { 00078 if (mutex == NULL) 00079 { 00080 xp_print("dazuko: warning: xp_destroy_mutex(NULL)\n"); 00081 return -1; 00082 } 00083 00084 return xp_destroy_mutex(mutex); 00085 } 00086 00087 00088 /* read-write lock */ 00089 00090 inline int call_xp_init_rwlock(struct xp_rwlock *rwlock) 00091 { 00092 if (rwlock == NULL) 00093 { 00094 xp_print("dazuko: warning: xp_init_rwlock(NULL)\n"); 00095 return -1; 00096 } 00097 00098 return xp_init_rwlock(rwlock); 00099 } 00100 00101 inline int call_xp_write_lock(struct xp_rwlock *rwlock) 00102 { 00103 if (rwlock == NULL) 00104 { 00105 xp_print("dazuko: warning: xp_write_lock(NULL)\n"); 00106 return -1; 00107 } 00108 00109 return xp_write_lock(rwlock); 00110 } 00111 00112 inline int call_xp_write_unlock(struct xp_rwlock *rwlock) 00113 { 00114 if (rwlock == NULL) 00115 { 00116 xp_print("dazuko: warning: xp_write_unlock(NULL)\n"); 00117 return -1; 00118 } 00119 00120 return xp_write_unlock(rwlock); 00121 } 00122 00123 inline int call_xp_read_lock(struct xp_rwlock *rlock) 00124 { 00125 if (rlock == NULL) 00126 { 00127 xp_print("dazuko: warning: xp_read_lock(NULL)\n"); 00128 return -1; 00129 } 00130 00131 return xp_read_lock(rlock); 00132 } 00133 00134 inline int call_xp_read_unlock(struct xp_rwlock *rlock) 00135 { 00136 if (rlock == NULL) 00137 { 00138 xp_print("dazuko: warning: xp_read_unlock(NULL)\n"); 00139 return -1; 00140 } 00141 00142 return xp_read_unlock(rlock); 00143 } 00144 00145 inline int call_xp_destroy_rwlock(struct xp_rwlock *rwlock) 00146 { 00147 if (rwlock == NULL) 00148 { 00149 xp_print("dazuko: warning: xp_destroy_rwlock(NULL)\n"); 00150 return -1; 00151 } 00152 00153 return xp_destroy_rwlock(rwlock); 00154 } 00155 00156 00157 /* wait-notify queue */ 00158 00159 inline int call_xp_init_queue(struct xp_queue *queue) 00160 { 00161 if (queue == NULL) 00162 { 00163 xp_print("dazuko: warning: xp_init_queue(NULL)\n"); 00164 return -1; 00165 } 00166 00167 return xp_init_queue(queue); 00168 } 00169 00170 inline int call_xp_wait_until_condition(struct xp_queue *queue, int (*cfunction)(void *), void *cparam, int allow_interrupt) 00171 { 00172 if (queue == NULL) 00173 { 00174 xp_print("dazuko: warning: xp_wait_until_condition(queue=NULL)\n"); 00175 return -1; 00176 } 00177 00178 if (cfunction == NULL) 00179 { 00180 xp_print("dazuko: warning: xp_wait_until_condition(cfunction=NULL)\n"); 00181 return -1; 00182 } 00183 00184 return xp_wait_until_condition(queue, cfunction, cparam, allow_interrupt); 00185 } 00186 00187 inline int call_xp_notify(struct xp_queue *queue) 00188 { 00189 if (queue == NULL) 00190 { 00191 xp_print("dazuko: warning: xp_notify(NULL)\n"); 00192 return -1; 00193 } 00194 00195 return xp_notify(queue); 00196 } 00197 00198 inline int call_xp_destroy_queue(struct xp_queue *queue) 00199 { 00200 if (queue == NULL) 00201 { 00202 xp_print("dazuko: warning: xp_destroy_queue(NULL)\n"); 00203 return -1; 00204 } 00205 00206 return xp_destroy_queue(queue); 00207 } 00208 00209 00210 /* memory */ 00211 00212 inline void* call_xp_malloc(size_t size) 00213 { 00214 void *ptr; 00215 00216 if (size < 1) 00217 { 00218 xp_print("dazuko: warning: xp_malloc(%d)\n", size); 00219 return NULL; 00220 } 00221 00222 ptr = xp_malloc(size); 00223 00224 if (ptr == NULL) 00225 xp_print("dazuko: warning: xp_malloc(%d) -> NULL\n", size); 00226 00227 return ptr; 00228 } 00229 00230 inline int call_xp_free(void *ptr) 00231 { 00232 if (ptr == NULL) 00233 { 00234 xp_print("dazuko: warning: xp_free(NULL)\n"); 00235 return 0; 00236 } 00237 00238 return xp_free(ptr); 00239 } 00240 00241 inline int call_xp_copyin(const void *user_src, void *kernel_dest, size_t size) 00242 { 00243 if (user_src == NULL) 00244 { 00245 xp_print("dazuko: warning: xp_copyin(user_src=NULL)\n"); 00246 return -1; 00247 } 00248 00249 if (kernel_dest == NULL) 00250 { 00251 xp_print("dazuko: warning: xp_copyin(kernel_dest=NULL)\n"); 00252 return -1; 00253 } 00254 00255 if (size < 1) 00256 { 00257 xp_print("dazuko: warning: xp_copyin(size=%d)\n", size); 00258 return 0; 00259 } 00260 00261 return xp_copyin(user_src, kernel_dest, size); 00262 } 00263 00264 inline int call_xp_copyout(const void *kernel_src, void *user_dest, size_t size) 00265 { 00266 if (kernel_src == NULL) 00267 { 00268 xp_print("dazuko: warning: xp_copyout(kernel_src=NULL)\n"); 00269 return -1; 00270 } 00271 00272 if (user_dest == NULL) 00273 { 00274 xp_print("dazuko: warning: xp_copyout(user_dest=NULL)\n"); 00275 return -1; 00276 } 00277 00278 if (size < 1) 00279 { 00280 xp_print("dazuko: warning: xp_copyout(size=%d)\n", size); 00281 return 0; 00282 } 00283 00284 return xp_copyout(kernel_src, user_dest, size); 00285 } 00286 00287 inline int call_xp_verify_user_writable(const void *user_ptr, size_t size) 00288 { 00289 if (user_ptr == NULL) 00290 { 00291 xp_print("dazuko: warning: xp_verify_user_writable(user_ptr=NULL)\n"); 00292 return -1; 00293 } 00294 00295 if (size < 1) 00296 { 00297 xp_print("dazuko: warning: xp_verify_user_writable(size=%d)\n", size); 00298 return -1; 00299 } 00300 00301 return xp_verify_user_writable(user_ptr, size); 00302 } 00303 00304 inline int call_xp_verify_user_readable(const void *user_ptr, size_t size) 00305 { 00306 if (user_ptr == NULL) 00307 { 00308 xp_print("dazuko: warning: xp_verify_user_readable(user_ptr=NULL)\n"); 00309 return -1; 00310 } 00311 00312 if (size < 1) 00313 { 00314 xp_print("dazuko: warning: xp_verify_user_readable(size=%d)\n", size); 00315 return -1; 00316 } 00317 00318 return xp_verify_user_readable(user_ptr, size); 00319 } 00320 00321 00322 /* path attribute */ 00323 00324 inline int call_xp_is_absolute_path(const char *path) 00325 { 00326 if (path == NULL) 00327 { 00328 xp_print("dazuko: warning: xp_is_absolute_path(NULL)\n"); 00329 return 0; 00330 } 00331 00332 return xp_is_absolute_path(path); 00333 } 00334 00335 00336 /* atomic */ 00337 00338 inline int call_xp_atomic_set(struct xp_atomic *atomic, int value) 00339 { 00340 if (atomic == NULL) 00341 { 00342 xp_print("dazuko: warning: xp_atomic_set(atomic=NULL)\n"); 00343 return -1; 00344 } 00345 00346 return xp_atomic_set(atomic, value); 00347 } 00348 00349 inline int call_xp_atomic_inc(struct xp_atomic *atomic) 00350 { 00351 if (atomic == NULL) 00352 { 00353 xp_print("dazuko: warning: xp_atomic_inc(NULL)\n"); 00354 return -1; 00355 } 00356 00357 return xp_atomic_inc(atomic); 00358 } 00359 00360 inline int call_xp_atomic_dec(struct xp_atomic *atomic) 00361 { 00362 if (atomic == NULL) 00363 { 00364 xp_print("dazuko: warning: xp_atomic_dec(NULL)\n"); 00365 return -1; 00366 } 00367 00368 return xp_atomic_dec(atomic); 00369 } 00370 00371 inline int call_xp_atomic_read(struct xp_atomic *atomic) 00372 { 00373 if (atomic == NULL) 00374 { 00375 xp_print("dazuko: warning: xp_atomic_read(NULL)\n"); 00376 return -1; 00377 } 00378 00379 return xp_atomic_read(atomic); 00380 } 00381 00382 00383 /* file descriptor */ 00384 00385 inline int call_xp_copy_file(struct xp_file *dest, struct xp_file *src) 00386 { 00387 if (dest == NULL) 00388 { 00389 xp_print("dazuko: warning: xp_copy_file(dest=NULL)\n"); 00390 return -1; 00391 } 00392 00393 if (src == NULL) 00394 { 00395 xp_print("dazuko: warning: xp_copy_file(src=NULL)\n"); 00396 return -1; 00397 } 00398 00399 return xp_copy_file(dest, src); 00400 } 00401 00402 inline int call_xp_compare_file(struct xp_file *file1, struct xp_file *file2) 00403 { 00404 if (file1 == NULL) 00405 { 00406 xp_print("dazuko: warning: xp_compare_file(file1=NULL)\n"); 00407 return -1; 00408 } 00409 00410 if (file2 == NULL) 00411 { 00412 xp_print("dazuko: warning: xp_compare_file(file2=NULL)\n"); 00413 return -1; 00414 } 00415 00416 return xp_compare_file(file1, file2); 00417 } 00418 00419 00420 /* file structure */ 00421 00422 inline int call_xp_file_struct_check(struct dazuko_file_struct *dfs) 00423 { 00424 if (dfs == NULL) 00425 { 00426 xp_print("dazuko: warning: xp_file_struct_check(NULL)\n"); 00427 return -1; 00428 } 00429 00430 return xp_file_struct_check(dfs); 00431 } 00432 00433 inline int call_xp_file_struct_check_cleanup(struct dazuko_file_struct *dfs) 00434 { 00435 if (dfs == NULL) 00436 { 00437 xp_print("dazuko: warning: xp_file_struct_check_cleanup(NULL)\n"); 00438 return 0; 00439 } 00440 00441 return xp_file_struct_check_cleanup(dfs); 00442 } 00443 00444 00445 /* daemon id */ 00446 00447 inline int call_xp_id_compare(struct xp_daemon_id *id1, struct xp_daemon_id *id2) 00448 { 00449 if (id1 == NULL) 00450 { 00451 xp_print("dazuko: warning: xp_id_compare(id1=NULL)\n"); 00452 return -1; 00453 } 00454 00455 if (id2 == NULL) 00456 { 00457 xp_print("dazuko: warning: xp_id_compare(id2=NULL)\n"); 00458 return -1; 00459 } 00460 00461 return xp_id_compare(id1, id2); 00462 } 00463 00464 inline int call_xp_id_free(struct xp_daemon_id *id) 00465 { 00466 if (id == NULL) 00467 { 00468 xp_print("dazuko: warning: xp_id_free(NULL)\n"); 00469 return 0; 00470 } 00471 00472 return xp_id_free(id); 00473 } 00474 00475 inline struct xp_daemon_id* call_xp_id_copy(struct xp_daemon_id *id) 00476 { 00477 struct xp_daemon_id *ptr; 00478 00479 if (id == NULL) 00480 { 00481 xp_print("dazuko: warning: xp_id_copy(NULL)\n"); 00482 return NULL; 00483 } 00484 00485 ptr = xp_id_copy(id); 00486 00487 if (ptr == NULL) 00488 xp_print("dazuko: warning: xp_id_copy() -> NULL\n"); 00489 00490 return ptr; 00491 }

Generated on Tue Aug 31 10:05:23 2004 for RSBAC by doxygen 1.3.8