Changeset 327
- Timestamp:
- Apr 6, 2011, 8:33:14 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/samhain_hide.c
r237 r327 122 122 /* The configure options (#defines) for the Kernel 123 123 */ 124 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 124 125 /* 2.6.19 (((2) << 16) + ((6) << 8) + (19)) */ 125 126 #define SH_KERNEL_MIN 132627 126 127 127 #if SH_KERNEL_NUMERIC >= SH_KERNEL_MIN 128 #if SH_KERNEL_NUMERIC >= KERNEL_VERSION(2,6,33) 129 #include <linux/generated/autoconf.h> 130 #else 131 #if SH_KERNEL_NUMERIC >= KERNEL_VERSION(2,6,19) 128 132 #include <linux/autoconf.h> 129 133 #else 130 134 #include <linux/config.h> 135 #endif 131 136 #endif 132 137 … … 182 187 */ 183 188 #include <linux/file.h> 189 #if SH_KERNEL_NUMERIC >= KERNEL_VERSION(2,6,26) 190 #include <linux/fdtable.h> 191 #endif 184 192 185 193 /***************************************************** … … 202 210 /* The old address of the sys_getdents syscall. 203 211 */ 212 #if SH_KERNEL_NUMERIC < KERNEL_VERSION(2,6,27) 204 213 int (*old_getdents)(unsigned int, struct dirent *, unsigned int); 214 #else 215 216 struct linux_dirent { 217 unsigned long d_ino; 218 unsigned long d_off; 219 unsigned short d_reclen; 220 char d_name[1]; 221 }; 222 223 int (*old_getdents)(unsigned int, struct linux_dirent *, unsigned int); 224 #endif 225 205 226 #ifdef __NR_getdents64 206 227 #if SH_KERNEL_NUMERIC >= 132628 … … 290 311 291 312 #else 292 /* 293 * RedHat 2.4.20 kernel 294 */ 313 #if SH_KERNEL_NUMERIC < KERNEL_VERSION(2,6,25) 295 314 struct task_struct * fetch_task_struct (int pid) 296 315 { … … 299 318 return (task_ptr); 300 319 } 320 #else 321 struct task_struct * fetch_task_struct (int pid) 322 { 323 struct task_struct * task_ptr = NULL; 324 struct pid * task_pid = find_vpid(pid); 325 if (task_pid) 326 { 327 task_ptr = pid_task (task_pid, PIDTYPE_PID); 328 } 329 return (task_ptr); 330 } 331 #endif 301 332 #endif 302 333 … … 345 376 * name. 346 377 */ 378 #if SH_KERNEL_NUMERIC < KERNEL_VERSION(2,6,27) 347 379 int new_getdents (unsigned int fd, struct dirent *dirp, unsigned int count) 380 #else 381 int new_getdents (unsigned int fd, struct linux_dirent *dirp, unsigned int count) 382 #endif 348 383 { 349 384 int status = 0; /* Return value from original getdents */ … … 352 387 int dir_is_proc = 0; 353 388 389 #if SH_KERNEL_NUMERIC < KERNEL_VERSION(2,6,27) 354 390 struct dirent * dirp_prev; 355 391 struct dirent * dirp_new; 356 392 struct dirent * dirp_current; 393 #else 394 struct linux_dirent * dirp_prev; 395 struct linux_dirent * dirp_new; 396 struct linux_dirent * dirp_current; 397 #endif 357 398 358 399 int dir_table_bytes; … … 413 454 * (kernel oops) 414 455 */ 456 #if SH_KERNEL_NUMERIC < KERNEL_VERSION(2,6,27) 415 457 dirp_new = (struct dirent *) kmalloc (status, GFP_ATOMIC); 458 #else 459 dirp_new = (struct linux_dirent *) kmalloc (status, GFP_ATOMIC); 460 #endif 416 461 417 462 if (dirp_new == NULL) … … 514 559 /* Next entry in dirp table. 515 560 */ 561 #if SH_KERNEL_NUMERIC < KERNEL_VERSION(2,6,27) 516 562 if (dir_table_bytes > 0) 517 563 dirp_current = (struct dirent *) ( (char *) dirp_current + 518 564 forward_bytes); 565 #else 566 if (dir_table_bytes > 0) 567 dirp_current = (struct linux_dirent *) ( (char *) dirp_current + 568 forward_bytes); 569 #endif 519 570 } 520 571 … … 534 585 return (status); 535 586 } 587 588 536 589 537 590 /* For 2.4 kernel … … 554 607 int dir_is_proc = 0; 555 608 609 #if SH_KERNEL_NUMERIC < KERNEL_VERSION(2,6,27) 556 610 struct dirent64 * dirp_prev; 557 611 struct dirent64 * dirp_new; 558 612 struct dirent64 * dirp_current; 613 #else 614 struct linux_dirent64 * dirp_prev; 615 struct linux_dirent64 * dirp_new; 616 struct linux_dirent64 * dirp_current; 617 #endif 559 618 560 619 int dir_table_bytes; … … 764 823 /* Next entry in dirp table. 765 824 */ 825 #if SH_KERNEL_NUMERIC < KERNEL_VERSION(2,6,27) 766 826 if (dir_table_bytes > 0) 767 827 dirp_current = (struct dirent64 *) ( (char *) dirp_current + 768 828 forward_bytes); 829 #else 830 if (dir_table_bytes > 0) 831 dirp_current = (struct linux_dirent64 *) ( (char *) dirp_current + 832 forward_bytes); 833 #endif 769 834 } 770 835 … … 786 851 787 852 #ifdef LINUX26 788 static struct module * find_module(const char *name)853 static struct module *sh_find_module(const char *name) 789 854 { 790 855 struct module *mod; … … 833 898 spinlock_t * modlist_lock = (spinlock_t * ) SH_MODLIST_LOCK; 834 899 #endif 900 #if SH_KERNEL_NUMERIC >= KERNEL_VERSION(2,6,30) 901 struct mutex * sh_module_mutex = &module_mutex; 902 #else 903 #if (SH_KERNEL_NUMERIC >= SH_KERNEL_MIN) 904 struct mutex * sh_module_mutex = (struct mutex *) SH_MODLIST_MUTEX; 905 #endif 906 #endif 907 908 struct module *mod; 909 835 910 #if SH_KERNEL_NUMERIC >= SH_KERNEL_MIN 836 struct mutex * module_mutex = (struct mutex *) SH_MODLIST_MUTEX; 837 #endif 838 839 struct module *mod; 840 841 #if SH_KERNEL_NUMERIC >= SH_KERNEL_MIN 842 mutex_lock(module_mutex); 843 #endif 844 845 mod = find_module(SH_INSTALL_NAME"_hide"); 911 mutex_lock(sh_module_mutex); 912 #endif 913 914 mod = sh_find_module(SH_INSTALL_NAME"_hide"); 846 915 if (mod) { 847 916 /* Delete from various lists */ … … 858 927 } 859 928 #if SH_KERNEL_NUMERIC >= SH_KERNEL_MIN 860 mutex_unlock( module_mutex);929 mutex_unlock(sh_module_mutex); 861 930 #endif 862 931 } … … 881 950 */ 882 951 sh_sys_call_table[SYS_getdents] = (unsigned long) old_getdents; 952 883 953 #ifdef __NR_getdents64 884 954 sh_sys_call_table[SYS_getdents64] = (unsigned long) old_getdents64;
Note:
See TracChangeset
for help on using the changeset viewer.