isert-scst: Stop polling before indexing a failed CQ result

Manual review found that isert_poll_cq forms &cq->wc[err] when
ib_poll_cq returns a negative errno. This pointer formation already
indexes outside the completion array, even if the following loop does
not dereference it. No saved analyzer diagnostic directly reports it.

Stop on nonpositive results before forming the end pointer and preserve
the result for the caller. Keep the loop exit next to the poll result.

Add the scst-ISER-cq KUnit suite to isert-scst.ko. Call the production
polling function with a private ib_device poll callback and task-local
stubs for the success and error completion handlers. Cover initial
-EIO and -EINVAL results, an empty queue, full and short batches, and
an error after completions. Check poll termination, completion order
and dispatch to the correct handler. Negative-result cases also exercise
kernel UBSAN bounds checking when CONFIG_UBSAN_BOUNDS is enabled.

Include iSER in the existing KUnit module inventory and build it after
iscsi-scst with the RDMA compatibility probes. Propagate the common
KUnit flags through ordinary iSER builds as well, so analyzer builds
include the suite. Extend tooling checks for module selection, dependency
order, cleanup, private headers and in-tree source export.
This commit is contained in:
Gleb Chesnokov
2026-10-21 13:20:12 +03:00
parent 6eba9234a2
commit e4a191c109
12 changed files with 230 additions and 17 deletions
+2
View File
@@ -44,6 +44,8 @@ class CleanTests(unittest.TestCase):
'scst/src/dev_handlers/kunit/vdisk/suites/test.o',
'iscsi-scst/kernel/iscsi-scst.ko',
'iscsi-scst/kernel/kunit/suites/test.o',
'iscsi-scst/kernel/isert-scst/isert-scst.ko',
'iscsi-scst/kernel/isert-scst/kunit/suites/test.o',
'qla2x00t-32gbit/qla2xxx_scst.ko',
'qla2x00t-32gbit/qla_os.o',
'qla2x00t-32gbit/qla2x00-target/qla2x00tgt.ko',
+1
View File
@@ -80,6 +80,7 @@ download_and_extract_kernel_tree() {
owners = {'scst/src': 'drivers/scst',
'scst/src/dev_handlers': 'drivers/scst/dev_handlers',
'iscsi-scst/kernel': 'drivers/scst/iscsi-scst',
'iscsi-scst/kernel/isert-scst': 'drivers/scst/iscsi-scst/isert-scst',
'qla2x00t-32gbit/qla2x00-target': 'drivers/scsi/qla2xxx'}
for source_dir, target_dir in owners.items():
for header in (ROOT / source_dir).glob('*_test.h'):
+1
View File
@@ -11,6 +11,7 @@ ROOT = Path(__file__).resolve().parents[2]
class HeaderTests(unittest.TestCase):
def test_normal_headers_do_not_require_kernel_or_test_types(self):
directories = ('scst/src', 'scst/src/dev_handlers', 'iscsi-scst/kernel',
'iscsi-scst/kernel/isert-scst',
'qla2x00t-32gbit/qla2x00-target')
headers = sorted(header for directory in directories
for header in (ROOT / directory).glob('*_test.h'))
+17 -2
View File
@@ -28,6 +28,8 @@ OWNERS = {
'scst_vdisk': ('scst/src/dev_handlers', 'scst/kernel/in-tree/Makefile.dev_handlers'),
'scst_user': ('scst/src/dev_handlers', 'scst/kernel/in-tree/Makefile.dev_handlers'),
'iscsi-scst': ('iscsi-scst/kernel', 'iscsi-scst/kernel/Makefile.in-kernel'),
'isert-scst': ('iscsi-scst/kernel/isert-scst',
'iscsi-scst/kernel/isert-scst/Makefile.in-kernel'),
'qla2x00tgt': ('qla2x00t-32gbit/qla2x00-target',
'qla2x00t-32gbit/Makefile_in-tree'),
}
@@ -239,6 +241,7 @@ class SelectionTests(unittest.TestCase):
kdir = root / 'kernel'
(kdir / 'include/config').mkdir(parents=True)
(kdir / 'include/config/kernel.release').write_text('kunit-build-test\n')
(kdir / '.config').write_text('CONFIG_INFINIBAND=m\n')
fields = ['$(patsubst $(KUNIT_TEST_ROOT)/%,%,$(M))', '$(KUNIT_LABEL)', '$(KDIR)',
'$(KVER)', '$(ARCH)', '$(CROSS_COMPILE)', '$(CC)',
'$(PASS_CC_TO_MAKE)', '$(WERROR)']
@@ -249,10 +252,12 @@ class SelectionTests(unittest.TestCase):
'built_module = $(if $(filter all,$@),'
'$(if $(filter $(qla_root),$(M)),qla2xxx_scst.ko,'
'$(if $(filter $(qla_root)/qla2x00-target,$(M)),qla2x00tgt.ko,all)),$@)\n'
'.PHONY: all scst.ko scst_vdisk.ko scst_user.ko iscsi-scst.ko\n'
'all scst.ko scst_vdisk.ko scst_user.ko iscsi-scst.ko:\n'
'.PHONY: all scst.ko scst_vdisk.ko scst_user.ko iscsi-scst.ko isert-scst.ko\n'
'all scst.ko scst_vdisk.ko scst_user.ko iscsi-scst.ko isert-scst.ko:\n'
'\t@test "$(M)" = "$(KUNIT_TEST_ROOT)/scst/src" || '
'test -f "$(KUNIT_TEST_ROOT)/scst/src/Module.symvers"\n'
'\t@test "$(M)" != "$(KUNIT_TEST_ROOT)/iscsi-scst/kernel/isert-scst" || '
'test -f "$(KUNIT_TEST_ROOT)/iscsi-scst/kernel/Module.symvers"\n'
'\t@test "$(M)" != "$(qla_root)/qla2x00-target" || '
'test -f "$(qla_root)/Module.symvers"\n'
'\t@test "$(M)" != "$(qla_root)" || '
@@ -331,6 +336,16 @@ class SelectionTests(unittest.TestCase):
result, rows, modules, _, _ = self.build_components('KUNIT_LABEL=' + selection)
self.assert_full_build(result, rows, modules)
def test_iser_requires_rdma_and_propagates_build_failures(self):
for options in ({'options': ('INFINIBAND_ENABLED=false',)},
{'fail': 'iscsi-scst/kernel/isert-scst'}):
with self.subTest(options=options):
result, _, modules, events, _ = self.build_components(
*options.get('options', ()), fail=options.get('fail', ''))
self.assertNotEqual(result.returncode, 0)
self.assertIsNone(modules)
self.assertNotIn('runner', events)
def test_normal_build_keeps_tests_disabled(self):
for selection in (None, 'LIB'):
result, rows, _, events, _ = self.build_components(goals=('scst',), selection=selection)