@@ -1519,7 +1519,6 @@ static void Astra(void) {
15191519 if (VfsCreateFile (astra_path ) != 0 ) PANIC ("Failed to create Astra process info file" );
15201520
15211521 PrintKernelSuccess ("Astra: Astra active.\n" );
1522-
15231522 uint64_t last_check = 0 ;
15241523
15251524 uint64_t last_integrity_scan = 0 ;
@@ -1605,27 +1604,21 @@ static void Astra(void) {
16051604 }
16061605#endif
16071606
1608- if (LIKELY (VfsIsFile (astra_path ))) {
1609- if (current_tick % 1000 == 0 ) {
1610- char buff [1 ] = {0 };
1611- int rd = VfsReadFile (astra_path , buff , sizeof (buff ));
1612- if (rd > 0 ) {
1613- switch (buff [0 ]) {
1614- case 'p' : PANIC ("Astra: CRITICAL: Manual panic triggered via ProcINFO\n" ); break ;
1615- case 't' : threat_level += 10 ; break ; // for fun
1616- case 'k' : ASTerminate (current -> pid , "ProcINFO" ); break ;
1617- case 'a' : CreateSecureProcess (Astra , PROC_PRIV_SYSTEM , PROC_FLAG_CORE ); break ;
1618- default : break ;
1619- }
1620- int del_rc = VfsDelete (astra_path , false);
1621- int cr_rc = VfsCreateFile (astra_path );
1622- if (del_rc != 0 || (cr_rc != 0 && !VfsIsFile (astra_path ))) {
1623- PrintKernelWarning ("Astra: ProcINFO reset failed\n" );
1624- }
1625- }
1607+ if (current_tick % 250 == 0 ) {
1608+ char buff [1 ] = {0 };
1609+ if (VfsReadFile (astra_path , buff , sizeof (buff )) == -1 ) PANIC ("Failed to read Astra process info file" );
1610+ switch (buff [0 ]) {
1611+ case 'p' : PANIC ("Astra: CRITICAL: Manual panic triggered via ProcINFO\n" ); break ;
1612+ case 't' : threat_level += 10 ; break ; // for fun
1613+ case 'k' : ASTerminate (current -> pid , "ProcINFO" ); break ;
1614+ case 'a' : CreateSecureProcess (Astra , PROC_PRIV_SYSTEM , PROC_FLAG_CORE ); break ;
1615+ default : break ;
1616+ }
1617+ int del_rc = VfsDelete (astra_path , false);
1618+ int cr_rc = VfsCreateFile (astra_path );
1619+ if (del_rc != 0 || (cr_rc != 0 && !VfsIsFile (astra_path ))) {
1620+ PANIC ("Astra: ProcINFO reset failed\n" );
16261621 }
1627- } else {
1628- (void )VfsCreateFile (astra_path );
16291622 }
16301623
16311624 // 1. Token integrity verification
@@ -1957,4 +1950,4 @@ void MLFQGetProcessStats(uint32_t pid, uint32_t* cpu_time, uint32_t* io_ops, uin
19571950 if (io_ops ) * io_ops = proc -> io_operations ;
19581951 if (preemptions ) * preemptions = proc -> preemption_count ;
19591952 ReadUnlock (& process_table_rwlock , pid );
1960- }
1953+ }
0 commit comments