Эх сурвалжийг харах

Merge tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux

Pull module preemption fix from Rusty Russell:
 "Turns out we should have always been disabling preemption here;
  someone finally caught it thanks to Peter Z's additional checks"

* tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
  module: Fix locking in symbol_put_addr()
Linus Torvalds 9 жил өмнө
parent
commit
9e17f90702
1 өөрчлөгдсөн 6 нэмэгдсэн , 2 устгасан
  1. 6 2
      kernel/module.c

+ 6 - 2
kernel/module.c

@@ -1063,11 +1063,15 @@ void symbol_put_addr(void *addr)
 	if (core_kernel_text(a))
 	if (core_kernel_text(a))
 		return;
 		return;
 
 
-	/* module_text_address is safe here: we're supposed to have reference
-	 * to module from symbol_get, so it can't go away. */
+	/*
+	 * Even though we hold a reference on the module; we still need to
+	 * disable preemption in order to safely traverse the data structure.
+	 */
+	preempt_disable();
 	modaddr = __module_text_address(a);
 	modaddr = __module_text_address(a);
 	BUG_ON(!modaddr);
 	BUG_ON(!modaddr);
 	module_put(modaddr);
 	module_put(modaddr);
+	preempt_enable();
 }
 }
 EXPORT_SYMBOL_GPL(symbol_put_addr);
 EXPORT_SYMBOL_GPL(symbol_put_addr);