On Mon, May 29, 2023 at 07:00:05AM -0400, Linus Torvalds wrote: > However, can I ask you to just verify that it was purely the exclusive > open part, and it wasn't that I messed up something else. IOW, can you > replace the > > return exclusive_deny_write_access(file); > > in prepare_file_for_module_load() with just a "return 0", and remove the > > allow_write_access(f.file); > > line in finit_module()? > > That's obviously _instead_ of the revert that I already pushed out, > just to verify that "yup, it's that part, not something silly > elsewhere" Yes, those two changes are enough to make the problem go away. > I do wonder what it is that is different in your setup, and maybe you > could also enable the > > pr_debug("finit_module: fd=%d, uargs=%p, flags=%i\n", fd, uargs, flags); Below is the corresponding output with a working kernel: 174 requests for the 131 modules that end up being loaded (without the revert there is only around 110 modules loaded). There is some probe deferral and async probing going on during normal boot which may be part of the explanation. Johan [ 0.669112] finit_module: fd=3, uargs=00000000b461506c, flags=0 [ 0.674144] finit_module: fd=4, uargs=00000000b461506c, flags=0 [ 0.676783] finit_module: fd=5, uargs=00000000b461506c, flags=0 [ 0.678920] finit_module: fd=3, uargs=00000000b461506c, flags=0 [ 0.837967] finit_module: fd=5, uargs=0000000000157d9f, flags=0 [ 0.839414] finit_module: fd=3, uargs=00000000b461506c, flags=0 [ 0.844129] finit_module: fd=4, uargs=00000000b461506c, flags=0 [ 0.845016] finit_module: fd=3, uargs=00000000b461506c, flags=0 [ 0.849132] finit_module: fd=3, uargs=00000000b461506c, flags=0 [ 0.849460] finit_module: fd=4, uargs=00000000b461506c, flags=0 [ 3.345004] finit_module: fd=4, uargs=00000000e3e6c6d2, flags=0 [ 3.364302] finit_module: fd=4, uargs=0000000095136ea7, flags=0 [ 3.371928] finit_module: fd=5, uargs=0000000095136ea7, flags=0 [ 4.099183] finit_module: fd=3, uargs=00000000ce2d6f3e, flags=0 [ 4.103156] finit_module: fd=3, uargs=000000004e3e14c2, flags=0 [ 4.713558] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.715608] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.717620] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.717910] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.719517] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.725862] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.726730] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.727018] finit_module: fd=14, uargs=00000000262da138, flags=0 [ 4.730525] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.749602] finit_module: fd=15, uargs=00000000262da138, flags=0 [ 4.749675] finit_module: fd=15, uargs=00000000262da138, flags=0 [ 4.749678] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.774117] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.795307] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.797327] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.798405] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.799140] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.800850] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.807306] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.807313] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.807321] finit_module: fd=16, uargs=00000000262da138, flags=0 [ 4.807394] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.807463] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.807525] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.807530] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.807590] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.811469] finit_module: fd=0, uargs=0000000080fab15b, flags=0 [ 4.845851] finit_module: fd=15, uargs=00000000262da138, flags=0 [ 4.845875] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.846282] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.846363] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.846363] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.846669] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.846994] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.847005] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.847194] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.847356] finit_module: fd=15, uargs=00000000262da138, flags=0 [ 4.847448] finit_module: fd=17, uargs=00000000262da138, flags=0 [ 4.847556] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.847651] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.848175] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.850005] finit_module: fd=15, uargs=00000000262da138, flags=0 [ 4.850485] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.866031] finit_module: fd=15, uargs=00000000262da138, flags=0 [ 4.866032] finit_module: fd=16, uargs=00000000262da138, flags=0 [ 4.866381] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.866711] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.867757] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.868360] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.886043] finit_module: fd=16, uargs=00000000262da138, flags=0 [ 4.886046] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.886046] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.886060] finit_module: fd=17, uargs=00000000262da138, flags=0 [ 4.886114] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.886140] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.886326] finit_module: fd=15, uargs=00000000262da138, flags=0 [ 4.886716] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.887210] finit_module: fd=16, uargs=00000000262da138, flags=0 [ 4.887451] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.887811] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.887963] finit_module: fd=15, uargs=00000000262da138, flags=0 [ 4.892066] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.896048] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.896070] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.896092] finit_module: fd=15, uargs=00000000262da138, flags=0 [ 4.896157] finit_module: fd=18, uargs=00000000262da138, flags=0 [ 4.896193] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.896211] finit_module: fd=18, uargs=00000000262da138, flags=0 [ 4.896737] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.896751] finit_module: fd=15, uargs=00000000262da138, flags=0 [ 4.897174] finit_module: fd=15, uargs=00000000262da138, flags=0 [ 4.897343] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.897388] finit_module: fd=19, uargs=00000000262da138, flags=0 [ 4.897555] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.897592] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.899657] finit_module: fd=16, uargs=00000000262da138, flags=0 [ 4.899973] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 4.900316] finit_module: fd=17, uargs=00000000262da138, flags=0 [ 4.901188] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.901668] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.901708] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.902030] finit_module: fd=15, uargs=00000000262da138, flags=0 [ 4.903964] finit_module: fd=14, uargs=00000000262da138, flags=0 [ 4.905243] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.907083] finit_module: fd=17, uargs=00000000262da138, flags=0 [ 4.907480] finit_module: fd=16, uargs=00000000262da138, flags=0 [ 4.907519] finit_module: fd=16, uargs=00000000262da138, flags=0 [ 4.909481] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 4.911705] finit_module: fd=15, uargs=00000000262da138, flags=0 [ 4.912056] finit_module: fd=18, uargs=00000000262da138, flags=0 [ 4.912079] finit_module: fd=15, uargs=00000000262da138, flags=0 [ 4.915340] finit_module: fd=19, uargs=00000000262da138, flags=0 [ 4.933199] finit_module: fd=16, uargs=00000000262da138, flags=0 [ 4.933585] finit_module: fd=18, uargs=00000000262da138, flags=0 [ 4.935169] finit_module: fd=20, uargs=00000000262da138, flags=0 [ 4.956021] finit_module: fd=19, uargs=00000000262da138, flags=0 [ 4.956797] finit_module: fd=16, uargs=00000000262da138, flags=0 [ 4.959865] finit_module: fd=17, uargs=00000000262da138, flags=0 [ 4.964171] finit_module: fd=17, uargs=00000000262da138, flags=0 [ 4.977073] finit_module: fd=18, uargs=00000000262da138, flags=0 [ 4.980167] finit_module: fd=18, uargs=00000000262da138, flags=0 [ 5.043379] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 5.053709] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 5.131232] finit_module: fd=15, uargs=00000000262da138, flags=0 [ 5.140785] finit_module: fd=19, uargs=00000000262da138, flags=0 [ 5.186244] finit_module: fd=18, uargs=00000000262da138, flags=0 [ 5.186247] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 5.186252] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 5.186451] finit_module: fd=15, uargs=00000000262da138, flags=0 [ 5.186507] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 5.187345] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 5.190282] finit_module: fd=15, uargs=00000000262da138, flags=0 [ 5.195744] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 5.198242] finit_module: fd=16, uargs=00000000262da138, flags=0 [ 5.198271] finit_module: fd=20, uargs=00000000262da138, flags=0 [ 5.222394] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 5.222395] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 5.222407] finit_module: fd=16, uargs=00000000262da138, flags=0 [ 5.222430] finit_module: fd=21, uargs=00000000262da138, flags=0 [ 5.222432] finit_module: fd=16, uargs=00000000262da138, flags=0 [ 5.222443] finit_module: fd=15, uargs=00000000262da138, flags=0 [ 5.229650] finit_module: fd=22, uargs=00000000262da138, flags=0 [ 5.257981] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 5.313560] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 6.144316] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 6.178956] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 6.178961] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 6.182057] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 6.182067] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 6.243708] finit_module: fd=0, uargs=00000000f9e4f67e, flags=0 [ 6.249397] finit_module: fd=0, uargs=000000001b26db10, flags=0 [ 6.249904] finit_module: fd=1, uargs=000000001b26db10, flags=0 [ 6.250626] finit_module: fd=2, uargs=000000001b26db10, flags=0 [ 6.251515] finit_module: fd=3, uargs=000000001b26db10, flags=0 [ 6.254112] finit_module: fd=4, uargs=000000001b26db10, flags=0 [ 6.255129] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 6.255504] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 6.259256] finit_module: fd=0, uargs=00000000e1b6cfe4, flags=0 [ 6.264136] finit_module: fd=0, uargs=000000004070418f, flags=0 [ 6.265227] finit_module: fd=1, uargs=000000004070418f, flags=0 [ 6.270175] finit_module: fd=0, uargs=0000000092757077, flags=0 [ 6.271230] finit_module: fd=1, uargs=0000000092757077, flags=0 [ 6.322960] finit_module: fd=3, uargs=00000000fb904223, flags=0 [ 6.373125] finit_module: fd=0, uargs=00000000e2cdc73f, flags=0 [ 6.380061] finit_module: fd=0, uargs=000000000591e4e9, flags=0 [ 6.392296] finit_module: fd=0, uargs=0000000088d2796a, flags=0 [ 6.464595] finit_module: fd=0, uargs=000000001aa8b42e, flags=0 [ 6.479839] finit_module: fd=0, uargs=00000000de50a030, flags=0 [ 6.488790] finit_module: fd=0, uargs=00000000cbcb6a65, flags=0 [ 6.492573] finit_module: fd=1, uargs=00000000cbcb6a65, flags=0 [ 6.514903] finit_module: fd=0, uargs=000000006f393376, flags=0 [ 7.989970] finit_module: fd=0, uargs=00000000c4594f52, flags=0 [ 11.492886] finit_module: fd=13, uargs=00000000262da138, flags=0 [ 11.639532] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 11.640048] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 11.640997] finit_module: fd=15, uargs=00000000262da138, flags=0 [ 11.641049] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 11.775051] finit_module: fd=6, uargs=00000000262da138, flags=0 [ 11.776806] finit_module: fd=6, uargs=00000000262da138, flags=0