@@ -203,7 +203,7 @@ int resolve_cred_offset()
203203 kernel_cap_t new_cap_e = { 0xff }, new_cap_i = { 0xf }, new_cap_p = { 0xfff };
204204 cap_capset (cred1 , cred , & new_cap_e , & new_cap_i , & new_cap_p );
205205
206- for (int i = 0 ; i < CRED_MAX_SIZE ; i += sizeof (kernel_cap_t )) {
206+ for (int i = 0 ; i < CRED_MAX_SIZE ; i += sizeof (uint32_t )) {
207207 if (is_bl (i )) continue ;
208208 kernel_cap_t cap = * (kernel_cap_t * )((uintptr_t )cred + i );
209209 kernel_cap_t cap1 = * (kernel_cap_t * )((uintptr_t )cred1 + i );
@@ -225,7 +225,7 @@ int resolve_cred_offset()
225225 }
226226
227227 // cap_bset
228- for (int i = 0 ; i < CRED_MAX_SIZE ; i += sizeof (kernel_cap_t )) {
228+ for (int i = 0 ; i < CRED_MAX_SIZE ; i += sizeof (uint32_t )) {
229229 if (is_bl (i )) continue ;
230230 kernel_cap_t cap1 = * (kernel_cap_t * )((uintptr_t )cred1 + i );
231231 if (cap1 .val == effective .val ) {
@@ -239,7 +239,7 @@ int resolve_cred_offset()
239239 log_boot (" cap_bset offset: %x\n" , cred_offset .cap_bset_offset );
240240
241241 // securebits
242- for (int i = 0 ; i < CRED_MAX_SIZE ; i += sizeof (unsigned )) {
242+ for (int i = 0 ; i < CRED_MAX_SIZE ; i += sizeof (uint32_t )) {
243243 if (is_bl (i )) continue ;
244244 unsigned * sbitsp = (unsigned * )((uintptr_t )cred + i );
245245 unsigned oribits = * sbitsp ;
@@ -257,7 +257,7 @@ int resolve_cred_offset()
257257 log_boot (" securebits offset: %x\n" , cred_offset .securebits_offset );
258258
259259 // euid, uid, egid, gid
260- for (int i = 0 ; i < CRED_MAX_SIZE ; i += sizeof (uid_t )) {
260+ for (int i = 0 ; i < CRED_MAX_SIZE ; i += sizeof (uint32_t )) {
261261 if (is_bl (i )) continue ;
262262 uid_t * uidp = (uid_t * )((uintptr_t )cred + i );
263263 if (* uidp ) continue ;
@@ -283,7 +283,7 @@ int resolve_cred_offset()
283283 log_boot (" egid offset: %x\n" , cred_offset .egid_offset );
284284
285285 // fsuid
286- for (int i = 0 ; i < CRED_MAX_SIZE ; i += sizeof (uid_t )) {
286+ for (int i = 0 ; i < CRED_MAX_SIZE ; i += sizeof (uint32_t )) {
287287 if (is_bl (i )) continue ;
288288 uid_t * uidp = (uid_t * )((uintptr_t )cred + i );
289289 uid_t backup = * uidp ;
@@ -300,7 +300,7 @@ int resolve_cred_offset()
300300
301301 // fsgid
302302 struct cred * new_cred = * (struct cred * * )((uintptr_t )task + task_struct_offset .cred_offset );
303- for (int i = 0 ; i < CRED_MAX_SIZE ; i += sizeof (gid_t )) {
303+ for (int i = 0 ; i < CRED_MAX_SIZE ; i += sizeof (uint32_t )) {
304304 if (is_bl (i )) continue ;
305305 gid_t * gidp = (gid_t * )((uintptr_t )new_cred + i );
306306 gid_t backup = * gidp ;
@@ -318,7 +318,7 @@ int resolve_cred_offset()
318318 // suid
319319 raw_syscall3 (__NR_setresuid , 0 , 0 , 1158 );
320320 new_cred = * (struct cred * * )((uintptr_t )task + task_struct_offset .cred_offset );
321- for (int i = 0 ; i < CRED_MAX_SIZE ; i += sizeof (uid_t )) {
321+ for (int i = 0 ; i < CRED_MAX_SIZE ; i += sizeof (uint32_t )) {
322322 if (is_bl (i )) continue ;
323323 uid_t * uidp = (uid_t * )((uintptr_t )new_cred + i );
324324 if (* uidp == 1158 ) {
@@ -333,7 +333,7 @@ int resolve_cred_offset()
333333 // sgid
334334 raw_syscall3 (__NR_setresgid , 0 , 0 , 1158 );
335335 new_cred = * (struct cred * * )((uintptr_t )task + task_struct_offset .cred_offset );
336- for (int i = 0 ; i < CRED_MAX_SIZE ; i += sizeof (gid_t )) {
336+ for (int i = 0 ; i < CRED_MAX_SIZE ; i += sizeof (uint32_t )) {
337337 if (is_bl (i )) continue ;
338338 gid_t * uidp = (gid_t * )((uintptr_t )new_cred + i );
339339 if (* uidp == 1158 ) {
@@ -353,7 +353,7 @@ int resolve_cred_offset()
353353 * (unsigned * )((uintptr_t )new_cred + cred_offset .securebits_offset ) = 0 ;
354354 cap_task_prctl (PR_CAP_AMBIENT , PR_CAP_AMBIENT_RAISE , 0xf , 0 , 0 );
355355 new_cred = * (struct cred * * )((uintptr_t )task + task_struct_offset .cred_offset );
356- for (int i = 0 ; i < CRED_MAX_SIZE ; i += sizeof (kernel_cap_t )) {
356+ for (int i = 0 ; i < CRED_MAX_SIZE ; i += sizeof (uint32_t )) {
357357 if (is_bl (i )) continue ;
358358 kernel_cap_t cap = * (kernel_cap_t * )((uintptr_t )cred + i );
359359 kernel_cap_t new_cap = * (kernel_cap_t * )((uintptr_t )new_cred + i );
@@ -379,7 +379,7 @@ static int find_swapper_comm_offset(uint64_t start, int size)
379379 if (!is_kimg_range (start ) || !is_kimg_range (start + size )) return -1 ;
380380 char swapper_comm [TASK_COMM_LEN ] = "swapper" ;
381381 char swapper_comm_1 [TASK_COMM_LEN ] = "swapper/0" ;
382- for (uint64_t i = start ; i < start + size ; i += 8 ) {
382+ for (uint64_t i = start ; i < start + size ; i += sizeof ( uint32_t ) ) {
383383 if (!lib_strcmp (swapper_comm , (char * )i ) || !lib_strcmp (swapper_comm_1 , (char * )i )) {
384384 return i - start ;
385385 }
@@ -401,7 +401,7 @@ int resolve_task_offset()
401401 int cred_offset_idx = 0 ;
402402 init_cred = get_task_cred (init_task ); // todo: get_task_cred not export
403403 log_boot (" init_cred addr: %llx\n" , init_cred );
404- for (uintptr_t i = (uintptr_t )init_task ; i < (uintptr_t )init_task + TASK_STRUCT_MAX_SIZE ; i += sizeof (uintptr_t )) {
404+ for (uintptr_t i = (uintptr_t )init_task ; i < (uintptr_t )init_task + TASK_STRUCT_MAX_SIZE ; i += sizeof (uint32_t )) {
405405 uintptr_t val = * (uintptr_t * )i ;
406406 if (val == (uintptr_t )init_cred ) {
407407 cred_offset [cred_offset_idx ++ ] = i - (uintptr_t )init_task ;
@@ -426,7 +426,7 @@ int resolve_task_offset()
426426
427427 // seccomp
428428 if (kfunc (prctl_get_seccomp )) {
429- for (uintptr_t i = (uintptr_t )task ; i < (uintptr_t )task + TASK_STRUCT_MAX_SIZE ; i += sizeof (uintptr_t )) {
429+ for (uintptr_t i = (uintptr_t )task ; i < (uintptr_t )task + TASK_STRUCT_MAX_SIZE ; i += sizeof (uint32_t )) {
430430 int * modep = (int * )i ;
431431 int mode_back = * modep ;
432432 if (mode_back ) continue ;
@@ -443,7 +443,7 @@ int resolve_task_offset()
443443 // active_mm
444444 init_mm = (struct mm_struct * )kallsyms_lookup_name ("init_mm" );
445445 if (init_mm ) {
446- for (uintptr_t i = (uintptr_t )task ; i < (uintptr_t )task + TASK_STRUCT_MAX_SIZE ; i += sizeof (uintptr_t )) {
446+ for (uintptr_t i = (uintptr_t )task ; i < (uintptr_t )task + TASK_STRUCT_MAX_SIZE ; i += sizeof (uint32_t )) {
447447 uintptr_t active_mm = * (uintptr_t * )i ;
448448 if (active_mm == (uintptr_t )init_mm ) {
449449 task_struct_offset .active_mm_offset = i - (uintptr_t )task ;
@@ -516,7 +516,7 @@ int resolve_current()
516516 uint64_t sp_low = sp & ~(tsz - 1 );
517517 // uint64_t sp_high = sp_low + tsz; // user_stack_pointer
518518 uint64_t psp = sp_low ;
519- for (; psp < sp_low + THREAD_INFO_MAX_SIZE ; psp += 8 ) {
519+ for (; psp < sp_low + THREAD_INFO_MAX_SIZE ; psp += sizeof ( uint32_t ) ) {
520520 if (* (uint64_t * )psp == STACK_END_MAGIC ) {
521521 if (psp == sp_low ) {
522522 thread_size = tsz ;
@@ -544,15 +544,15 @@ int resolve_current()
544544 if (!thread_info_in_task ) {
545545 uint64_t thread_info_addr = (uint64_t )current_thread_info_sp ();
546546 if (init_task ) {
547- for (uint64_t ptr = thread_info_addr ; ptr < thread_info_addr + stack_end_offset ; ptr += sizeof (uint64_t )) {
547+ for (uint64_t ptr = thread_info_addr ; ptr < thread_info_addr + stack_end_offset ; ptr += sizeof (uint32_t )) {
548548 uint64_t pv = * (uint64_t * )ptr ;
549549 if (pv == (uint64_t )init_task ) {
550550 task_in_thread_info_offset = ptr - thread_info_addr ;
551551 break ;
552552 }
553553 }
554554 } else { // unlikely
555- for (uint64_t ptr = thread_info_addr ; ptr < thread_info_addr + stack_end_offset ; ptr += sizeof (uint64_t )) {
555+ for (uint64_t ptr = thread_info_addr ; ptr < thread_info_addr + stack_end_offset ; ptr += sizeof (uint32_t )) {
556556 uint64_t pv = * (uint64_t * )ptr ;
557557 task_struct_offset .comm_offset = find_swapper_comm_offset (pv , TASK_STRUCT_MAX_SIZE );
558558 if (task_struct_offset .comm_offset > 0 ) {
@@ -573,7 +573,7 @@ int resolve_current()
573573
574574 // stack,
575575 uint64_t stack_base = (sp & ~(thread_size - 1 ));
576- for (uintptr_t i = (uintptr_t )init_task ; i < (uintptr_t )init_task + TASK_STRUCT_MAX_SIZE ; i += sizeof (uintptr_t )) {
576+ for (uintptr_t i = (uintptr_t )init_task ; i < (uintptr_t )init_task + TASK_STRUCT_MAX_SIZE ; i += sizeof (uint32_t )) {
577577 uintptr_t val = * (uintptr_t * )i ;
578578 if (stack_base == val ) {
579579 stack_in_task_offset = i - (uintptr_t )init_task ;
@@ -599,7 +599,7 @@ int resolve_mm_struct_offset()
599599 uintptr_t init_mm_addr = (uintptr_t )init_mm ;
600600 if (!init_mm_addr ) return 0 ;
601601
602- for (uintptr_t i = init_mm_addr ; i < init_mm_addr + MM_STRUCT_MAX_SIZE ; i += sizeof (uintptr_t )) {
602+ for (uintptr_t i = init_mm_addr ; i < init_mm_addr + MM_STRUCT_MAX_SIZE ; i += sizeof (uint32_t )) {
603603 uint64_t pgd = * (uintptr_t * )i ;
604604 if (pgd == phys_to_kimg (pgd_pa )) {
605605 mm_struct_offset .pgd_offset = i - init_mm_addr ;
0 commit comments