kernel/sysctl-test: Unregister sysctl table after test completion
Subsystems (2)
PATCH 1/1 kernel/sysctl-test: Unregister sysctl table after test completion
One of the sysctl tests registers a valid sysctl table. This operation is expected to succeed. However, it does not unregister the table after executing the test. If the code is built as module and the module is unloaded after the test, the next operation trying to access the table (such as 'sysctl -a') will trigger a crash.
Unregister the registered table after test completiion to solve the problem.
--- kernel/sysctl-test.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/sysctl-test.c +4 -1
@@ -374,6 +374,7 @@ static void sysctl_test_register_sysctl_sz_invalid_extra_value( struct kunit *test) {unsigned char data =0 ; +struct ctl_table_header *header;const struct ctl_table table_foo[] = { { .procname ="foo" ,
@@ -412,7 +413,9 @@ static void sysctl_test_register_sysctl_sz_invalid_extra_value(KUNIT_EXPECT_NULL (test,register_sysctl ("foo" , table_foo));KUNIT_EXPECT_NULL (test,register_sysctl ("foo" , table_bar)); -KUNIT_EXPECT_NOT_NULL (test,register_sysctl ("foo" , table_qux)); + header =register_sysctl ("foo" , table_qux); +KUNIT_EXPECT_NOT_NULL (test, header); +unregister_sysctl_table (header); }static struct kunit_case sysctl_test_cases[] = {
Signature · 1 line
2.45.2
Quoted 9 lines · Guenter Roeck
One of the sysctl tests registers a valid sysctl table. This operation is expected to succeed. However, it does not unregister the table after executing the test. If the code is built as module and the module is unloaded after the test, the next operation trying to access the table (such as 'sysctl -a') will trigger a crash.
Unregister the registered table after test completiion to solve the problem.
Never mind, I just learned that a very similar patch has been submitted last December or so but was rejected, and that the acceptable (?) fix seems to be stalled.
Sorry for the noise.
Guenter
Joel Granados
maintainerQuoted 11 lines · Guenter Roeck
Quoted 9 lines · Guenter Roeck
One of the sysctl tests registers a valid sysctl table. This operation is expected to succeed. However, it does not unregister the table after executing the test. If the code is built as module and the module is unloaded after the test, the next operation trying to access the table (such as 'sysctl -a') will trigger a crash.
Unregister the registered table after test completiion to solve the problem.
Quoted 7 lines
Never mind, I just learned that a very similar patch has been submitted last December or so but was rejected, and that the acceptable (?) fix seems to be stalled.
Sorry for the noise.
Guenter
Hey Guenter
It is part of what is getting sent for 6.16 [1]
That test will move out of kunit into self-test.
Best
Signature · 1 line
Joel Granados
Quoted 16 lines · Joel Granados
Quoted 15 lines · Guenter Roeck
Quoted 9 lines · Guenter Roeck
One of the sysctl tests registers a valid sysctl table. This operation is expected to succeed. However, it does not unregister the table after executing the test. If the code is built as module and the module is unloaded after the test, the next operation trying to access the table (such as 'sysctl -a') will trigger a crash.
Unregister the registered table after test completiion to solve the problem.
Never mind, I just learned that a very similar patch has been submitted last December or so but was rejected, and that the acceptable (?) fix seems to be stalled.
Quoted 9 lines
Quoted 3 lines
Sorry for the noise.
Guenter
Hey Guenter
It is part of what is getting sent for 6.16 [1]
That test will move out of kunit into self-test.
Yes, I was pointed to that. The version I have seen seems to assume that the test is running as module, because the created sysctl entry is removed in the module exit function. If built into the kernel, it would leave the debug entry in place after the test is complete. Also, it moves the affected set of tests out of the kunit infrastructure. Is that accurate or a misunderstanding on my side ?
No criticism or objection, I am just trying to understand the direction of unit testing and specifically of the kunit infrastructure going forward.
Thanks,
Guenter
Joel Granados
maintainerQuoted 27 lines · Guenter Roeck
Quoted 16 lines · Joel Granados
Quoted 15 lines · Guenter Roeck
Quoted 9 lines · Guenter Roeck
One of the sysctl tests registers a valid sysctl table. This operation is expected to succeed. However, it does not unregister the table after executing the test. If the code is built as module and the module is unloaded after the test, the next operation trying to access the table (such as 'sysctl -a') will trigger a crash.
Unregister the registered table after test completiion to solve the problem.
Never mind, I just learned that a very similar patch has been submitted last December or so but was rejected, and that the acceptable (?) fix seems to be stalled.
Quoted 9 lines
Quoted 3 lines
Sorry for the noise.
Guenter
Hey Guenter
It is part of what is getting sent for 6.16 [1]
That test will move out of kunit into self-test.
Quoted 6 lines
Yes, I was pointed to that. The version I have seen seems to assume that the test is running as module, because the created sysctl entry is removed in the module exit function. If built into the kernel, it would leave the debug entry in place after the test is complete. Also, it moves the affected set of tests out of the kunit infrastructure. Is that accurate or a misunderstanding on my side ?
You have understood correctly. That is what the sysctl selftest does at least. It all runs together with tools/testing/sefltests/sysctl/*. The idea is to use CONFIG_TEST_SYSCTL only for testing purposes.
Best
Signature · 1 line
Joel Granados