Message ID | 20240605005612.216263-1-yi.zhang@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [blktests] block: add regression test for null-blk concurrently power/submit_queues test | expand |
oops, please ignore this one, will update with V2. On Wed, Jun 5, 2024 at 9:00 AM Yi Zhang <yi.zhang@redhat.com> wrote: > > null-blk currently power/submit_queues operations which will lead kernel > null-ptr-dereference[1], add one regression test for it and the fix has > been merged to v6.10-rc1 by [2]. > [1] > https://lore.kernel.org/linux-block/CAHj4cs9LgsHLnjg8z06LQ3Pr5cax-+Ps+xT7AP7TPnEjStuwZA@mail.gmail.com/ > https://lore.kernel.org/linux-block/20240523153934.1937851-1-yukuai1@huaweicloud.com/ > [2] > commit a2db328b0839 ("null_blk: fix null-ptr-dereference while configuring 'power' and 'submit_queues'") > > Signed-off-by: Yi Zhang <yi.zhang@redhat.com> > --- > tests/block/038 | 63 +++++++++++++++++++++++++++++++++++++++++++++ > tests/block/038.out | 2 ++ > 2 files changed, 65 insertions(+) > create mode 100755 tests/block/038 > create mode 100644 tests/block/038.out > > diff --git a/tests/block/038 b/tests/block/038 > new file mode 100755 > index 0000000..2122e10 > --- /dev/null > +++ b/tests/block/038 > @@ -0,0 +1,63 @@ > +#!/bin/bash > +# SPDX-License-Identifier: GPL-3.0+ > +# Copyright (C) 2024 Yi Zhang <yi.zhang@redhat.com> > +# > +# Regression test for commit a2db328b0839 ("null_blk: fix null-ptr-dereference > +# while configuring 'power' and 'submit_queues'"). > + > +. tests/block/rc > +. common/null_blk > + > +DESCRIPTION="Test null-blk concurrent power/submit_queues operations" > +QUICK=1 > + > +requires() { > + _have_module null_blk > + _have_module_param null_blk nr_devices > + _have_module_param null_blk submit_queues > +} > + > +null_blk_power_loop() { > + local nullb="$1" > + for ((i = 1; i <= 200; i++)); do > + echo 1 > "/sys/kernel/config/nullb/${nullb}/power" > + echo 0 > "/sys/kernel/config/nullb/${nullb}/power" > + echo $i >>/root/power.log > + done > +} > + > +null_blk_submit_queues_loop() { > + local nullb="$1" > + for ((i = 1; i <= 200; i++)); do > + echo 1 > "/sys/kernel/config/nullb/${nullb}/submit_queues" > + echo 4 > "/sys/kernel/config/nullb/${nullb}/submit_queues" > + echo $i >>/root/submit_uqeues.log > + done > +} > + > +test() { > + echo "Running ${TEST_NAME}" > + > + local nullb_params=( > + nr_devices=0 > + ) > + if ! _init_null_blk "${nullb_params[@]}"; then > + echo "Loading null_blk failed" > + return 1 > + fi > + > + if ! _configure_null_blk nullb0; then > + echo "Configuring null_blk nullb0 failed" > + return 1 > + fi > + > + # fire off two null-blk power/submit_queues concurrently and wait > + # for them to complete... > + null_blk_power_loop nullb0 & > + null_blk_submit_queues_loop nullb0 & > + wait > + > + _exit_null_blk > + > + echo "Test complete" > +} > diff --git a/tests/block/038.out b/tests/block/038.out > new file mode 100644 > index 0000000..aebde64 > --- /dev/null > +++ b/tests/block/038.out > @@ -0,0 +1,2 @@ > +Running block/038 > +Test complete > -- > 2.44.0 > >
diff --git a/tests/block/038 b/tests/block/038 new file mode 100755 index 0000000..2122e10 --- /dev/null +++ b/tests/block/038 @@ -0,0 +1,63 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2024 Yi Zhang <yi.zhang@redhat.com> +# +# Regression test for commit a2db328b0839 ("null_blk: fix null-ptr-dereference +# while configuring 'power' and 'submit_queues'"). + +. tests/block/rc +. common/null_blk + +DESCRIPTION="Test null-blk concurrent power/submit_queues operations" +QUICK=1 + +requires() { + _have_module null_blk + _have_module_param null_blk nr_devices + _have_module_param null_blk submit_queues +} + +null_blk_power_loop() { + local nullb="$1" + for ((i = 1; i <= 200; i++)); do + echo 1 > "/sys/kernel/config/nullb/${nullb}/power" + echo 0 > "/sys/kernel/config/nullb/${nullb}/power" + echo $i >>/root/power.log + done +} + +null_blk_submit_queues_loop() { + local nullb="$1" + for ((i = 1; i <= 200; i++)); do + echo 1 > "/sys/kernel/config/nullb/${nullb}/submit_queues" + echo 4 > "/sys/kernel/config/nullb/${nullb}/submit_queues" + echo $i >>/root/submit_uqeues.log + done +} + +test() { + echo "Running ${TEST_NAME}" + + local nullb_params=( + nr_devices=0 + ) + if ! _init_null_blk "${nullb_params[@]}"; then + echo "Loading null_blk failed" + return 1 + fi + + if ! _configure_null_blk nullb0; then + echo "Configuring null_blk nullb0 failed" + return 1 + fi + + # fire off two null-blk power/submit_queues concurrently and wait + # for them to complete... + null_blk_power_loop nullb0 & + null_blk_submit_queues_loop nullb0 & + wait + + _exit_null_blk + + echo "Test complete" +} diff --git a/tests/block/038.out b/tests/block/038.out new file mode 100644 index 0000000..aebde64 --- /dev/null +++ b/tests/block/038.out @@ -0,0 +1,2 @@ +Running block/038 +Test complete
null-blk currently power/submit_queues operations which will lead kernel null-ptr-dereference[1], add one regression test for it and the fix has been merged to v6.10-rc1 by [2]. [1] https://lore.kernel.org/linux-block/CAHj4cs9LgsHLnjg8z06LQ3Pr5cax-+Ps+xT7AP7TPnEjStuwZA@mail.gmail.com/ https://lore.kernel.org/linux-block/20240523153934.1937851-1-yukuai1@huaweicloud.com/ [2] commit a2db328b0839 ("null_blk: fix null-ptr-dereference while configuring 'power' and 'submit_queues'") Signed-off-by: Yi Zhang <yi.zhang@redhat.com> --- tests/block/038 | 63 +++++++++++++++++++++++++++++++++++++++++++++ tests/block/038.out | 2 ++ 2 files changed, 65 insertions(+) create mode 100755 tests/block/038 create mode 100644 tests/block/038.out