Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kernel/notifier.c: intercept duplicate registrations to avoid infinit…
…e loops Registering the same notifier to a hook repeatedly can cause the hook list to form a ring or lose other members of the list. case1: An infinite loop in notifier_chain_register() can cause soft lockup atomic_notifier_chain_register(&test_notifier_list, &test1); atomic_notifier_chain_register(&test_notifier_list, &test1); atomic_notifier_chain_register(&test_notifier_list, &test2); case2: An infinite loop in notifier_chain_register() can cause soft lockup atomic_notifier_chain_register(&test_notifier_list, &test1); atomic_notifier_chain_register(&test_notifier_list, &test1); atomic_notifier_call_chain(&test_notifier_list, 0, NULL); case3: lose other hook test2 atomic_notifier_chain_register(&test_notifier_list, &test1); atomic_notifier_chain_register(&test_notifier_list, &test2); atomic_notifier_chain_register(&test_notifier_list, &test1); case4: Unregister returns 0, but the hook is still in the linked list, and it is not really registered. If you call notifier_call_chain after ko is unloaded, it will trigger oops. If the system is configured with softlockup_panic and the same hook is repeatedly registered on the panic_notifier_list, it will cause a loop panic. Add a check in notifier_chain_register(), intercepting duplicate registrations to avoid infinite loops Link: http:https://lkml.kernel.org/r/[email protected] Signed-off-by: Xiaoming Ni <[email protected]> Reviewed-by: Vasily Averin <[email protected]> Reviewed-by: Andrew Morton <[email protected]> Cc: Alexey Dobriyan <[email protected]> Cc: Anna Schumaker <[email protected]> Cc: Arjan van de Ven <[email protected]> Cc: J. Bruce Fields <[email protected]> Cc: Chuck Lever <[email protected]> Cc: David S. Miller <[email protected]> Cc: Jeff Layton <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Nadia Derbey <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Cc: Sam Protsenko <[email protected]> Cc: Alan Stern <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Trond Myklebust <[email protected]> Cc: Viresh Kumar <[email protected]> Cc: Xiaoming Ni <[email protected]> Cc: YueHaibing <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
- Loading branch information