module: convert to stop_machine_create/destroy.

The module code relies on a non-failing stop_machine call. So we create
the kstop threads in advance and with that make sure the call won't fail.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

authored by

Heiko Carstens and committed by
Rusty Russell
9e01892c 9ea09af3

+21 -2
+21 -2
kernel/module.c
··· 757 return -EFAULT; 758 name[MODULE_NAME_LEN-1] = '\0'; 759 760 - if (mutex_lock_interruptible(&module_mutex) != 0) 761 - return -EINTR; 762 763 mod = find_module(name); 764 if (!mod) { ··· 825 826 out: 827 mutex_unlock(&module_mutex); 828 return ret; 829 } 830 ··· 1885 /* vmalloc barfs on "unusual" numbers. Check here */ 1886 if (len > 64 * 1024 * 1024 || (hdr = vmalloc(len)) == NULL) 1887 return ERR_PTR(-ENOMEM); 1888 if (copy_from_user(hdr, umod, len) != 0) { 1889 err = -EFAULT; 1890 goto free_hdr; ··· 2275 /* Get rid of temporary copy */ 2276 vfree(hdr); 2277 2278 /* Done! */ 2279 return mod; 2280 ··· 2298 kfree(args); 2299 free_hdr: 2300 vfree(hdr); 2301 return ERR_PTR(err); 2302 2303 truncated:
··· 757 return -EFAULT; 758 name[MODULE_NAME_LEN-1] = '\0'; 759 760 + /* Create stop_machine threads since free_module relies on 761 + * a non-failing stop_machine call. */ 762 + ret = stop_machine_create(); 763 + if (ret) 764 + return ret; 765 + 766 + if (mutex_lock_interruptible(&module_mutex) != 0) { 767 + ret = -EINTR; 768 + goto out_stop; 769 + } 770 771 mod = find_module(name); 772 if (!mod) { ··· 817 818 out: 819 mutex_unlock(&module_mutex); 820 + out_stop: 821 + stop_machine_destroy(); 822 return ret; 823 } 824 ··· 1875 /* vmalloc barfs on "unusual" numbers. Check here */ 1876 if (len > 64 * 1024 * 1024 || (hdr = vmalloc(len)) == NULL) 1877 return ERR_PTR(-ENOMEM); 1878 + 1879 + /* Create stop_machine threads since the error path relies on 1880 + * a non-failing stop_machine call. */ 1881 + err = stop_machine_create(); 1882 + if (err) 1883 + goto free_hdr; 1884 + 1885 if (copy_from_user(hdr, umod, len) != 0) { 1886 err = -EFAULT; 1887 goto free_hdr; ··· 2258 /* Get rid of temporary copy */ 2259 vfree(hdr); 2260 2261 + stop_machine_destroy(); 2262 /* Done! */ 2263 return mod; 2264 ··· 2280 kfree(args); 2281 free_hdr: 2282 vfree(hdr); 2283 + stop_machine_destroy(); 2284 return ERR_PTR(err); 2285 2286 truncated: