Hi, Add module parameter verification make sure we are not deling with the negative value that also fixes follwing Oops :- linux-block (for-next) # modprobe null_blk poll_queues=-2 Entering kdb (current=0xffff88817eaed100, pid 5624) on processor 12 Oops: (null) due to oops @ 0xffffffff8165093f CPU: 12 PID: 5624 Comm: modprobe Tainted: G OE 6.0.0-rc7blk+ #53 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 RIP: 0010:blk_mq_alloc_tag_set+0x14f/0x380 Code: 83 c5 01 3b 6b 40 0f 83 9a 01 00 00 48 8b 43 68 4c 63 e5 4e 8d 34 e0 f6 43 58 08 75 d7 8b 53 44 89 ee 48 89 df e8 d1 ed ff ff <49> 89 06 48 8b 43 68 4a 83 3c e0 00 75 c3 83 ed 01 78 0f 89 ee 48 RSP: 0018:ffffc90002eefd70 EFLAGS: 00010282 RAX: ffff888112b155c0 RBX: ffff88811069dc38 RCX: 0000000000000003 RDX: ffff88811069d000 RSI: ffff88810ed60000 RDI: 00000000000001f8 RBP: 0000000000000000 R08: 0000000000000003 R09: ffff888112b15650 R10: 000000000010ed60 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000040 R14: 0000000000000000 R15: 0000000000000000 FS: 00007f71e4147b80(0000) GS:ffff888fff500000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 000000014d81c000 CR4: 0000000000350ee0 Call Trace: <TASK> null_add_dev+0x7a7/0x870 [null_blk] null_init+0x1de/0x1000 [null_blk] ? 0xffffffffc03a9000 do_one_initcall+0x44/0x210 ? kmem_cache_alloc_trace+0x15b/0x2b0 do_init_module+0x4c/0x1f0 __do_sys_finit_module+0xb4/0x130 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f71e426e15d Code: c5 0c 00 0f 05 eb a9 66 0f 1f 44 00 00 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d e3 7c 0c 00 f7 d8 64 89 01 48 RSP: 002b:00007fffb29f27a8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 RAX: ffffffffffffffda RBX: 0000564b29d78b90 RCX: 00007f71e426e15d RDX: 0000000000000000 RSI: 0000564b29d78f00 RDI: 0000000000000003 RBP: 0000000000040000 R08: 0000000000000000 R09: 0000000000000020 R10: 0000000000000003 R11: 0000000000000246 R12: 0000564b29d78f00 R13: 0000564b29d78cc0 R14: 0000564b29d78b90 R15: 0000564b29d78f20 </TASK> [12]kdb> -ck Chaitanya Kulkarni (6): null_blk: check for valid submit_queue value null_blk: check for valid poll_queue value null_blk: check for valid gb value null_blk: check for valid block size value null_blk: check for valid max_sectors value null_blk: check for valid queue depth value drivers/block/null_blk/main.c | 107 +++++++++++++++++++++++++++------- 1 file changed, 85 insertions(+), 22 deletions(-) Test Report :- ilinux-block (for-next) # sh ./test-mod-param.sh ################################################### poll_queues: ------------------------------------ modprobe null_blk poll_queues=2 [ 1924.377679] null_blk: disk nullb0 created [ 1924.377688] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=4 [ 1924.677126] null_blk: disk nullb0 created [ 1924.677131] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=8 [ 1924.971561] null_blk: disk nullb0 created [ 1924.971566] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=16 [ 1925.274443] null_blk: disk nullb0 created [ 1925.274448] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=32 [ 1925.576851] null_blk: disk nullb0 created [ 1925.576856] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=64 [ 1925.891751] null_blk: disk nullb0 created [ 1925.891755] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=128 [ 1926.195455] null_blk: disk nullb0 created [ 1926.195460] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=256 [ 1926.503886] null_blk: disk nullb0 created [ 1926.503890] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=512 [ 1926.834959] null_blk: disk nullb0 created [ 1926.834965] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=1024 [ 1927.201886] null_blk: disk nullb0 created [ 1927.201891] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=2048 [ 1927.616806] nullb0: AHDI p1 p3 [ 1927.616920] nullb0: p3 size 4294949121 extends beyond EOD, truncated [ 1927.616978] null_blk: disk nullb0 created [ 1927.616979] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=4096 [ 1928.117183] null_blk: disk nullb0 created [ 1928.117188] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=8192 [ 1928.797501] null_blk: disk nullb0 created [ 1928.797506] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=16384 [ 1929.849149] null_blk: disk nullb0 created [ 1929.849154] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=32768 [ 1931.577964] null_blk: disk nullb0 created [ 1931.577969] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=65536 modprobe: ERROR: could not insert 'null_blk': Cannot allocate memory ------------------------------------ modprobe null_blk poll_queues=131072 modprobe: ERROR: could not insert 'null_blk': Cannot allocate memory ------------------------------------ modprobe null_blk poll_queues=262144 modprobe: ERROR: could not insert 'null_blk': Cannot allocate memory ------------------------------------ modprobe null_blk poll_queues=524288 modprobe: ERROR: could not insert 'null_blk': Cannot allocate memory ------------------------------------ modprobe null_blk poll_queues=1048576 modprobe: ERROR: could not insert 'null_blk': Cannot allocate memory ------------------------------------ modprobe null_blk poll_queues=2097152 modprobe: ERROR: could not insert 'null_blk': Cannot allocate memory ------------------------------------ modprobe null_blk poll_queues=4194304 modprobe: ERROR: could not insert 'null_blk': Cannot allocate memory ------------------------------------ modprobe null_blk poll_queues=8388608 modprobe: ERROR: could not insert 'null_blk': Cannot allocate memory ------------------------------------ modprobe null_blk poll_queues=16777216 modprobe: ERROR: could not insert 'null_blk': Cannot allocate memory ------------------------------------ modprobe null_blk poll_queues=33554432 modprobe: ERROR: could not insert 'null_blk': Cannot allocate memory ------------------------------------ modprobe null_blk poll_queues=67108864 modprobe: ERROR: could not insert 'null_blk': Cannot allocate memory ------------------------------------ modprobe null_blk poll_queues=134217728 modprobe: ERROR: could not insert 'null_blk': Cannot allocate memory ------------------------------------ modprobe null_blk poll_queues=268435456 modprobe: ERROR: could not insert 'null_blk': Cannot allocate memory ------------------------------------ modprobe null_blk poll_queues=536870912 modprobe: ERROR: could not insert 'null_blk': Cannot allocate memory ------------------------------------ modprobe null_blk poll_queues=1073741824 modprobe: ERROR: could not insert 'null_blk': Cannot allocate memory ------------------------------------ modprobe null_blk poll_queues=2147483648 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1937.008217] null_blk: `2147483648' invalid for parameter `poll_queues' ------------------------------------ modprobe null_blk poll_queues=4294967296 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1937.290366] null_blk: `4294967296' invalid for parameter `poll_queues' ################################################### submit_queues: ------------------------------------ modprobe null_blk submit_queues=2 [ 1937.585539] null_blk: disk nullb0 created [ 1937.585544] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=4 [ 1937.880302] null_blk: disk nullb0 created [ 1937.880306] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=8 [ 1938.174551] null_blk: disk nullb0 created [ 1938.174555] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=16 [ 1938.477783] null_blk: disk nullb0 created [ 1938.477787] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=32 [ 1938.770354] null_blk: disk nullb0 created [ 1938.770359] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=64 [ 1939.074975] null_blk: disk nullb0 created [ 1939.074979] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=128 [ 1939.370133] null_blk: disk nullb0 created [ 1939.370138] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=256 [ 1939.663309] null_blk: disk nullb0 created [ 1939.663313] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=512 [ 1939.970666] null_blk: disk nullb0 created [ 1939.970671] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=1024 [ 1940.267200] null_blk: disk nullb0 created [ 1940.267203] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=2048 [ 1940.569051] null_blk: disk nullb0 created [ 1940.569055] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=4096 [ 1940.869073] null_blk: disk nullb0 created [ 1940.869076] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=8192 [ 1941.170419] null_blk: disk nullb0 created [ 1941.170423] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=16384 [ 1941.473582] null_blk: disk nullb0 created [ 1941.473586] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=32768 [ 1941.766981] null_blk: disk nullb0 created [ 1941.766985] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=65536 [ 1942.069883] null_blk: disk nullb0 created [ 1942.069887] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=131072 [ 1942.362132] null_blk: disk nullb0 created [ 1942.362137] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=262144 [ 1942.661742] null_blk: disk nullb0 created [ 1942.661747] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=524288 [ 1942.955668] null_blk: disk nullb0 created [ 1942.955673] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=1048576 [ 1943.249454] null_blk: disk nullb0 created [ 1943.249459] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=2097152 [ 1943.550678] null_blk: disk nullb0 created [ 1943.550683] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=4194304 [ 1943.856922] null_blk: disk nullb0 created [ 1943.856927] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=8388608 [ 1944.173595] null_blk: disk nullb0 created [ 1944.173600] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=16777216 [ 1944.472637] null_blk: disk nullb0 created [ 1944.472641] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=33554432 [ 1944.767623] null_blk: disk nullb0 created [ 1944.767627] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=67108864 [ 1945.073317] null_blk: disk nullb0 created [ 1945.073321] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=134217728 [ 1945.380609] null_blk: disk nullb0 created [ 1945.380613] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=268435456 [ 1945.677736] null_blk: disk nullb0 created [ 1945.677740] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=536870912 [ 1945.975502] null_blk: disk nullb0 created [ 1945.975506] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=1073741824 [ 1946.272191] null_blk: disk nullb0 created [ 1946.272195] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=2147483648 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1946.566080] null_blk: `2147483648' invalid for parameter `submit_queues' ------------------------------------ modprobe null_blk submit_queues=4294967296 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1946.847997] null_blk: `4294967296' invalid for parameter `submit_queues' ################################################### hw_queue_depth: ------------------------------------ modprobe null_blk hw_queue_depth=-2 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1947.127929] null_blk: `-2' invalid for parameter `hw_queue_depth' ------------------------------------ modprobe null_blk hw_queue_depth=-1 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1947.161958] null_blk: `-1' invalid for parameter `hw_queue_depth' ------------------------------------ modprobe null_blk hw_queue_depth=0 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1947.192521] null_blk: `0' invalid for parameter `hw_queue_depth' ------------------------------------ modprobe null_blk hw_queue_depth=1 [ 1947.222359] null_blk: disk nullb0 created [ 1947.222363] null_blk: module loaded ------------------------------------ modprobe null_blk hw_queue_depth=2 [ 1947.270471] null_blk: disk nullb0 created [ 1947.270476] null_blk: module loaded ------------------------------------ modprobe null_blk hw_queue_depth=4 [ 1947.318861] null_blk: disk nullb0 created [ 1947.318865] null_blk: module loaded ------------------------------------ modprobe null_blk hw_queue_depth=8 [ 1947.368261] null_blk: disk nullb0 created [ 1947.368265] null_blk: module loaded ------------------------------------ modprobe null_blk hw_queue_depth=32 [ 1947.422207] null_blk: disk nullb0 created [ 1947.422210] null_blk: module loaded ------------------------------------ modprobe null_blk hw_queue_depth=64 [ 1947.469696] null_blk: disk nullb0 created [ 1947.469699] null_blk: module loaded ################################################### max_sectors: ------------------------------------ modprobe null_blk max_sectors=-2 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1947.518538] null_blk: `-2' invalid for parameter `max_sectors' ------------------------------------ modprobe null_blk max_sectors=-1 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1947.548179] null_blk: `-1' invalid for parameter `max_sectors' ------------------------------------ modprobe null_blk max_sectors=0 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1947.584591] null_blk: `0' invalid for parameter `max_sectors' ------------------------------------ modprobe null_blk max_sectors=1 [ 1947.621178] blk_queue_max_hw_sectors: set to minimum 8 [ 1947.622980] null_blk: disk nullb0 created [ 1947.622983] null_blk: module loaded ------------------------------------ modprobe null_blk max_sectors=2 [ 1947.673349] blk_queue_max_hw_sectors: set to minimum 8 [ 1947.675181] null_blk: disk nullb0 created [ 1947.675184] null_blk: module loaded ------------------------------------ modprobe null_blk max_sectors=4 [ 1947.742695] blk_queue_max_hw_sectors: set to minimum 8 [ 1947.744392] null_blk: disk nullb0 created [ 1947.744395] null_blk: module loaded ------------------------------------ modprobe null_blk max_sectors=8 [ 1947.790072] null_blk: disk nullb0 created [ 1947.790076] null_blk: module loaded ------------------------------------ modprobe null_blk max_sectors=32 [ 1947.833683] null_blk: disk nullb0 created [ 1947.833686] null_blk: module loaded ------------------------------------ modprobe null_blk max_sectors=64 [ 1947.879298] null_blk: disk nullb0 created [ 1947.879302] null_blk: module loaded ################################################### gb: ------------------------------------ modprobe null_blk gb=-2 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1947.936630] null_blk: `-2' invalid for parameter `gb' ------------------------------------ modprobe null_blk gb=-1 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1947.965811] null_blk: `-1' invalid for parameter `gb' ------------------------------------ modprobe null_blk gb=0 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1948.000246] null_blk: `0' invalid for parameter `gb' ------------------------------------ modprobe null_blk gb=1 [ 1948.031978] null_blk: disk nullb0 created [ 1948.031981] null_blk: module loaded ------------------------------------ modprobe null_blk gb=2 [ 1948.076624] null_blk: disk nullb0 created [ 1948.076628] null_blk: module loaded ------------------------------------ modprobe null_blk gb=4 [ 1948.128380] null_blk: disk nullb0 created [ 1948.128385] null_blk: module loaded ------------------------------------ modprobe null_blk gb=8 [ 1948.189039] null_blk: disk nullb0 created [ 1948.189043] null_blk: module loaded ------------------------------------ modprobe null_blk gb=32 [ 1948.242571] null_blk: disk nullb0 created [ 1948.242576] null_blk: module loaded ------------------------------------ modprobe null_blk gb=64 [ 1948.288508] null_blk: disk nullb0 created [ 1948.288512] null_blk: module loaded ################################################### poll_queues: ------------------------------------ modprobe null_blk poll_queues=-2 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1948.338489] null_blk: `-2' invalid for parameter `poll_queues' ------------------------------------ modprobe null_blk poll_queues=-1 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1948.366555] null_blk: `-1' invalid for parameter `poll_queues' ------------------------------------ modprobe null_blk poll_queues=0 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1948.396045] null_blk: `0' invalid for parameter `poll_queues' ------------------------------------ modprobe null_blk poll_queues=1 [ 1948.431236] null_blk: disk nullb0 created [ 1948.431240] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=2 [ 1948.483416] null_blk: disk nullb0 created [ 1948.483420] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=4 [ 1948.531614] null_blk: disk nullb0 created [ 1948.531617] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=8 [ 1948.579633] null_blk: disk nullb0 created [ 1948.579638] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=32 [ 1948.628638] null_blk: disk nullb0 created [ 1948.628643] null_blk: module loaded ------------------------------------ modprobe null_blk poll_queues=64 [ 1948.686840] null_blk: disk nullb0 created [ 1948.686845] null_blk: module loaded ################################################### submit_queues: ------------------------------------ modprobe null_blk submit_queues=-2 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1948.735486] null_blk: `-2' invalid for parameter `submit_queues' ------------------------------------ modprobe null_blk submit_queues=-1 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1948.764503] null_blk: `-1' invalid for parameter `submit_queues' ------------------------------------ modprobe null_blk submit_queues=0 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1948.794944] null_blk: `0' invalid for parameter `submit_queues' ------------------------------------ modprobe null_blk submit_queues=1 [ 1948.826061] null_blk: disk nullb0 created [ 1948.826065] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=2 [ 1948.872684] null_blk: disk nullb0 created [ 1948.872688] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=4 [ 1948.928300] null_blk: disk nullb0 created [ 1948.928303] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=8 [ 1948.984935] null_blk: disk nullb0 created [ 1948.984939] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=32 [ 1949.034590] null_blk: disk nullb0 created [ 1949.034595] null_blk: module loaded ------------------------------------ modprobe null_blk submit_queues=64 [ 1949.085751] null_blk: disk nullb0 created [ 1949.085756] null_blk: module loaded ################################################### bs: ------------------------------------ modprobe null_blk bs=-2 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1949.130053] null_blk: `-2' invalid for parameter `bs' ------------------------------------ modprobe null_blk bs=-1 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1949.161179] null_blk: `-1' invalid for parameter `bs' ------------------------------------ modprobe null_blk bs=0 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1949.199904] null_blk: `0' invalid for parameter `bs' ------------------------------------ modprobe null_blk bs=1 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1949.229583] null_blk: `1' invalid for parameter `bs' ------------------------------------ modprobe null_blk bs=2 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1949.261719] null_blk: `2' invalid for parameter `bs' ------------------------------------ modprobe null_blk bs=4 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1949.292527] null_blk: `4' invalid for parameter `bs' ------------------------------------ modprobe null_blk bs=8 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1949.327845] null_blk: `8' invalid for parameter `bs' ------------------------------------ modprobe null_blk bs=32 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1949.358911] null_blk: `32' invalid for parameter `bs' ------------------------------------ modprobe null_blk bs=64 modprobe: ERROR: could not insert 'null_blk': Invalid argument [ 1949.387419] null_blk: `64' invalid for parameter `bs' ------------------------------------ modprobe null_blk bs=512 [ 1949.417564] null_blk: disk nullb0 created [ 1949.417567] null_blk: module loaded ------------------------------------ modprobe null_blk bs=1024 [ 1949.462782] null_blk: disk nullb0 created [ 1949.462786] null_blk: module loaded ------------------------------------ modprobe null_blk bs=2048 [ 1949.518958] null_blk: disk nullb0 created [ 1949.518961] null_blk: module loaded ------------------------------------ modprobe null_blk bs=4096 [ 1949.565926] null_blk: disk nullb0 created [ 1949.565931] null_blk: module loaded linux-block (for-next) # -- 2.29.0