When this was first reported [1], the possibility of having sufficient
number of dynamic misc devices was theoretical, in the case of dlm driver.
In practice, its userspace never created more than one device.
What we know from commit ab760791c0cf ("char: misc: Increase the maximum
number of dynamic misc devices to 1048448"), is that the miscdevice
interface has been used for allocating more than the single-shot devices it
was designed for. And it is not only coresight_tmc, but many other drivers
are able to create multiple devices.
On systems like the ones described in the above commit, it is certain that
the dynamic allocation will allocate certain reserved minor numbers,
leading to failures when a later driver tries to claim its reserved number.
Instead of excluding the historically statically allocated range from
dynamic allocation, restrict the latter to minors above 255.
Since commit ab760791c0cf ("char: misc: Increase the maximum number of
dynamic misc devices to 1048448") has been applied, such range is already
possible. And given such devices already need to be dynamically created,
there should be no systems where this might become a problem.
[1] https://lore.kernel.org/all/1257813017-28598-3-git-send-email-cascardo@holoscopio.com/
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
---
drivers/char/misc.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index f7dd455dd0dd3c7c9956e772b5ab8bd83a67a4a6..6a7f4f2f8d1227747a74be567bdc420a9e97f8f2 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -69,13 +69,8 @@ static int misc_minor_alloc(int minor)
if (minor == MISC_DYNAMIC_MINOR) {
/* allocate free id */
- ret = ida_alloc_max(&misc_minors_ida, DYNAMIC_MINORS - 1, GFP_KERNEL);
- if (ret >= 0) {
- ret = DYNAMIC_MINORS - ret - 1;
- } else {
- ret = ida_alloc_range(&misc_minors_ida, MISC_DYNAMIC_MINOR + 1,
- MINORMASK, GFP_KERNEL);
- }
+ ret = ida_alloc_range(&misc_minors_ida, MISC_DYNAMIC_MINOR + 1,
+ MINORMASK, GFP_KERNEL);
} else {
/* specific minor, check if it is in dynamic or misc dynamic range */
if (minor < DYNAMIC_MINORS) {
--
2.47.2
Hello,
kernel test robot noticed "kernel-selftests.sgx.test_sgx.enclave.unclobbered_vdso.fail" on:
commit: 47b2b7ca1ce4d1dbbaae0334436869c9e987d03c ("[PATCH v2 1/2] char: misc: restrict the dynamic range to exclude reserved minors")
url: https://github.com/intel-lab-lkp/linux/commits/Thadeu-Lima-de-Souza-Cascardo/char-misc-restrict-the-dynamic-range-to-exclude-reserved-minors/20250307-231711
patch link: https://lore.kernel.org/all/20250307-misc-dynrange-v2-1-6fe19032ef76@igalia.com/
patch subject: [PATCH v2 1/2] char: misc: restrict the dynamic range to exclude reserved minors
in testcase: kernel-selftests
version: kernel-selftests-x86_64-7ff71e6d9239-1_20250215
with following parameters:
group: sgx
config: x86_64-rhel-9.4-kselftests
compiler: gcc-12
test machine: 16 threads 1 sockets Intel(R) Xeon(R) E-2278G CPU @ 3.40GHz (Coffee Lake-E) with 32G memory
(please refer to attached dmesg/kmsg for entire log/backtrace)
here is a comparison with more details, cases failed upon this commit while
pass on parent:
=========================================================================================
tbox_group/testcase/rootfs/kconfig/compiler/group:
lkp-cfl-e1/kernel-selftests/debian-12-x86_64-20240206.cgz/x86_64-rhel-9.4-kselftests/gcc-12/sgx
2397d61ee45cddb8 47b2b7ca1ce4d1dbbaae0334436
---------------- ---------------------------
fail:runs %reproduction fail:runs
| | |
:9 67% 6:6 kernel-selftests.sgx.test_sgx.enclave.clobbered_vdso.fail
:9 67% 6:6 kernel-selftests.sgx.test_sgx.enclave.clobbered_vdso_and_user_function.fail
:9 67% 6:6 kernel-selftests.sgx.test_sgx.enclave.pte_permissions.fail
:9 67% 6:6 kernel-selftests.sgx.test_sgx.enclave.tcs_entry.fail
:9 67% 6:6 kernel-selftests.sgx.test_sgx.enclave.unclobbered_vdso.fail
:9 67% 6:6 kernel-selftests.sgx.test_sgx.enclave.unclobbered_vdso_oversubscribed.fail
:9 67% 6:6 kernel-selftests.sgx.test_sgx.fail
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <oliver.sang@intel.com>
| Closes: https://lore.kernel.org/oe-lkp/202503171507.6c8093d0-lkp@intel.com
2025-03-11 18:27:45 make quicktest=1 run_tests -C sgx
make: Entering directory '/usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-47b2b7ca1ce4d1dbbaae0334436869c9e987d03c/tools/testing/selftests/sgx'
TAP version 13
1..1
# timeout set to 300
# selftests: sgx: test_sgx
# TAP version 13
# 1..16
# # Starting 16 tests from 1 test cases.
# # RUN enclave.unclobbered_vdso ...
# Unable to open /dev/sgx_enclave: No such device or address
# # main.c:188:unclobbered_vdso:Failed to load the test enclave.
# # main.c:287:unclobbered_vdso:Expected 0 (0) != setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata) (0)
# # unclobbered_vdso: Test terminated by assertion
# # FAIL enclave.unclobbered_vdso
# not ok 1 enclave.unclobbered_vdso
# # RUN enclave.unclobbered_vdso_oversubscribed ...
# Unable to open /dev/sgx_enclave: No such device or address
# # main.c:188:unclobbered_vdso_oversubscribed:Failed to load the test enclave.
# # main.c:360:unclobbered_vdso_oversubscribed:Expected 0 (0) != setup_test_encl(total_mem, &self->encl, _metadata) (0)
# # unclobbered_vdso_oversubscribed: Test terminated by assertion
# # FAIL enclave.unclobbered_vdso_oversubscribed
# not ok 2 enclave.unclobbered_vdso_oversubscribed
# # RUN enclave.unclobbered_vdso_oversubscribed_remove ...
# # main.c:402:unclobbered_vdso_oversubscribed_remove:Creating an enclave with 198705152 bytes heap may take a while ...
# Unable to open /dev/sgx_enclave: No such device or address
# # main.c:188:unclobbered_vdso_oversubscribed_remove:Failed to load the test enclave.
# # main.c:404:unclobbered_vdso_oversubscribed_remove:Expected 0 (0) != setup_test_encl(total_mem, &self->encl, _metadata) (0)
# # unclobbered_vdso_oversubscribed_remove: Test terminated by assertion
# # FAIL enclave.unclobbered_vdso_oversubscribed_remove
# not ok 3 enclave.unclobbered_vdso_oversubscribed_remove
# # RUN enclave.clobbered_vdso ...
# Unable to open /dev/sgx_enclave: No such device or address
# # main.c:188:clobbered_vdso:Failed to load the test enclave.
# # main.c:509:clobbered_vdso:Expected 0 (0) != setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata) (0)
# # clobbered_vdso: Test terminated by assertion
# # FAIL enclave.clobbered_vdso
# not ok 4 enclave.clobbered_vdso
# # RUN enclave.clobbered_vdso_and_user_function ...
# Unable to open /dev/sgx_enclave: No such device or address
# # main.c:188:clobbered_vdso_and_user_function:Failed to load the test enclave.
# # main.c:545:clobbered_vdso_and_user_function:Expected 0 (0) != setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata) (0)
# # clobbered_vdso_and_user_function: Test terminated by assertion
# # FAIL enclave.clobbered_vdso_and_user_function
# not ok 5 enclave.clobbered_vdso_and_user_function
# # RUN enclave.tcs_entry ...
# Unable to open /dev/sgx_enclave: No such device or address
# # main.c:188:tcs_entry:Failed to load the test enclave.
# # main.c:578:tcs_entry:Expected 0 (0) != setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata) (0)
# # tcs_entry: Test terminated by assertion
# # FAIL enclave.tcs_entry
# not ok 6 enclave.tcs_entry
# # RUN enclave.pte_permissions ...
# Unable to open /dev/sgx_enclave: No such device or address
# # main.c:188:pte_permissions:Failed to load the test enclave.
# # main.c:623:pte_permissions:Expected 0 (0) != setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata) (0)
# # pte_permissions: Test terminated by assertion
# # FAIL enclave.pte_permissions
# not ok 7 enclave.pte_permissions
# # RUN enclave.tcs_permissions ...
# Unable to open /dev/sgx_enclave: No such device or address
# # main.c:188:tcs_permissions:Failed to load the test enclave.
# # main.c:725:tcs_permissions:Expected 0 (0) != setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata) (0)
# # tcs_permissions: Test terminated by assertion
# # FAIL enclave.tcs_permissions
# not ok 8 enclave.tcs_permissions
# # RUN enclave.epcm_permissions ...
# Unable to open /dev/sgx_enclave: No such device or address
# # main.c:188:epcm_permissions:Failed to load the test enclave.
# # main.c:788:epcm_permissions:Expected 0 (0) != setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata) (0)
# # epcm_permissions: Test terminated by assertion
# # FAIL enclave.epcm_permissions
# not ok 9 enclave.epcm_permissions
# # RUN enclave.augment ...
# # SKIP SGX2 not supported
# # OK enclave.augment
# ok 10 enclave.augment # SKIP SGX2 not supported
# # RUN enclave.augment_via_eaccept ...
# # SKIP SGX2 not supported
# # OK enclave.augment_via_eaccept
# ok 11 enclave.augment_via_eaccept # SKIP SGX2 not supported
# # RUN enclave.tcs_create ...
# Unable to open /dev/sgx_enclave: No such device or address
# # main.c:188:tcs_create:Failed to load the test enclave.
# # main.c:1240:tcs_create:Expected 0 (0) != setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata) (0)
# # tcs_create: Test terminated by assertion
# # FAIL enclave.tcs_create
# not ok 12 enclave.tcs_create
# # RUN enclave.remove_added_page_no_eaccept ...
# Unable to open /dev/sgx_enclave: No such device or address
# # main.c:188:remove_added_page_no_eaccept:Failed to load the test enclave.
# # main.c:1571:remove_added_page_no_eaccept:Expected 0 (0) != setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata) (0)
# # remove_added_page_no_eaccept: Test terminated by assertion
# # FAIL enclave.remove_added_page_no_eaccept
# not ok 13 enclave.remove_added_page_no_eaccept
# # RUN enclave.remove_added_page_invalid_access ...
# Unable to open /dev/sgx_enclave: No such device or address
# # main.c:188:remove_added_page_invalid_access:Failed to load the test enclave.
# # main.c:1682:remove_added_page_invalid_access:Expected 0 (0) != setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata) (0)
# # remove_added_page_invalid_access: Test terminated by assertion
# # FAIL enclave.remove_added_page_invalid_access
# not ok 14 enclave.remove_added_page_invalid_access
# # RUN enclave.remove_added_page_invalid_access_after_eaccept ...
# Unable to open /dev/sgx_enclave: No such device or address
# # main.c:188:remove_added_page_invalid_access_after_eaccept:Failed to load the test enclave.
# # main.c:1797:remove_added_page_invalid_access_after_eaccept:Expected 0 (0) != setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata) (0)
# # remove_added_page_invalid_access_after_eaccept: Test terminated by assertion
# # FAIL enclave.remove_added_page_invalid_access_after_eaccept
# not ok 15 enclave.remove_added_page_invalid_access_after_eaccept
# # RUN enclave.remove_untouched_page ...
# Unable to open /dev/sgx_enclave: No such device or address
# # main.c:188:remove_untouched_page:Failed to load the test enclave.
# # main.c:1921:remove_untouched_page:Expected 0 (0) != setup_test_encl(ENCL_HEAP_SIZE_DEFAULT, &self->encl, _metadata) (0)
# # remove_untouched_page: Test terminated by assertion
# # FAIL enclave.remove_untouched_page
# not ok 16 enclave.remove_untouched_page
# # FAILED: 2 / 16 tests passed.
# # 2 skipped test(s) detected. Consider enabling relevant config options to improve coverage.
# # Totals: pass:0 fail:14 xfail:0 xpass:0 skip:2 error:0
not ok 1 selftests: sgx: test_sgx # exit=1
make: Leaving directory '/usr/src/perf_selftests-x86_64-rhel-9.4-kselftests-47b2b7ca1ce4d1dbbaae0334436869c9e987d03c/tools/testing/selftests/sgx'
The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20250317/202503171507.6c8093d0-lkp@intel.com
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
© 2016 - 2026 Red Hat, Inc.