@@ -533,82 +533,3 @@ int syscalls_hc_init(void) {
533533 hash_init (syscall_hook_table );
534534 return 0 ;
535535}
536-
537- /* Deferred unregistration so we can invoke from inside a syscall callback */
538- struct deferred_unregister {
539- struct kernel_syscall_hook * hook ;
540- struct list_head list ;
541- };
542- static LIST_HEAD (deferred_unregister_list );
543- static DEFINE_SPINLOCK (deferred_unregister_lock );
544-
545- static void process_deferred_unregisters (struct work_struct * work )
546- {
547- struct deferred_unregister * deferred , * tmp ;
548- LIST_HEAD (local_list );
549-
550- // Move all pending unregistrations to local list
551- spin_lock (& deferred_unregister_lock );
552- list_splice_init (& deferred_unregister_list , & local_list );
553- spin_unlock (& deferred_unregister_lock );
554-
555- // Process unregistrations outside of spinlock
556- list_for_each_entry_safe (deferred , tmp , & local_list , list ) {
557- DBG_PRINTK ("IGLOO: Processing deferred unregistration for hook %p\n" ,
558- deferred -> hook );
559-
560- // Actually unregister the hook
561- unregister_syscall_hook (deferred -> hook );
562-
563- // Clean up the deferred entry
564- list_del (& deferred -> list );
565- kfree (deferred );
566- }
567- }
568-
569- static DECLARE_WORK (deferred_unregister_work , process_deferred_unregisters ) ;
570-
571- static int do_unregister_syscall_hook (struct kernel_syscall_hook * hook_ptr )
572- {
573- if (!hook_ptr ) {
574- return - EINVAL ;
575- }
576-
577- spin_lock (& syscall_hook_lock );
578-
579- hash_del (& hook_ptr -> hlist );
580- hlist_del_rcu (& hook_ptr -> name_hlist );
581-
582- spin_unlock (& syscall_hook_lock );
583-
584- kfree_rcu (hook_ptr , rcu );
585- atomic_dec (& global_syscall_hook_count );
586-
587- DBG_PRINTK ("IGLOO: Unregistered syscall hook %p\n" , hook_ptr );
588- return 0 ;
589- }
590-
591- // Modified unregister function
592- int unregister_syscall_hook (struct kernel_syscall_hook * hook_ptr )
593- {
594- struct deferred_unregister * deferred ;
595-
596- // Check if we're in syscall processing context
597- if (in_interrupt () || rcu_read_lock_held ()) {
598- // Defer the unregistration
599- deferred = kmalloc (sizeof (* deferred ), GFP_ATOMIC );
600- if (!deferred ) return - ENOMEM ;
601-
602- deferred -> hook = hook_ptr ;
603- spin_lock (& deferred_unregister_lock );
604- list_add_tail (& deferred -> list , & deferred_unregister_list );
605- spin_unlock (& deferred_unregister_lock );
606-
607- // Schedule work to process deferred unregistrations
608- schedule_work (& deferred_unregister_work );
609- return 0 ;
610- }
611-
612- // Safe to unregister immediately
613- return do_unregister_syscall_hook (hook_ptr );
614- }
0 commit comments