В ядре Linux была устранена следующая уязвимость: x86/amd_node: Fix potential NULL pointer dereference amd_smn_read/write() экспортируются функции вокруг __amd_smn_rw(), поэтому они всегда доступны, даже если amd_smn_init() выходит из строя. В этом случае 'amd_roots' - это NULL, а __amd_smn_rw() получит доступ к неинициализированной памяти. Затем, commit: 83518453074d («x86/amd_node: Add SMN смещения для эксклюзивного доступа к региону») добавил флаг «smn_exclusive», который указал, что вызовы в pci_request_config_region_exclusive() увенчались успехом, чтобы предотвратить одновременный доступ к пространству пользователя.
Commit: 0a4b61d9c2e4 ("x86/amd_node: Fix AMD root device caching») переупорядочил инициализацию, поэтому pci_request_config_region_exclusive() вызывается раньше, а отказ выходит из amd_smn_init() перед выделением 'amd_roots'. Настройка 'smn_exclusive' перенесена в конец amd_smn_init(), после выделения 'amd_roots'. Он стал излишним и может быть удален.
Замените 'smn_exclusive' прямой проверкой 'amd_roots', чтобы исправить возможное удаление указателя NULL и упростить логику. [ bp: Reorg commit message, touchup comment. ] [ mingo: Rebase & further touchups. ]
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: x86/amd_node: Fix potential NULL pointer dereference amd_smn_read/write() are exported functions around __amd_smn_rw(), so they are always available even if amd_smn_init() fails. In that case, 'amd_roots' is NULL and __amd_smn_rw() will access uninitialized memory. Then, commit: 83518453074d ("x86/amd_node: Add SMN offsets to exclusive region access") added the 'smn_exclusive' flag, which indicated the calls to pci_request_config_region_exclusive() succeeded, to prevent concurrent userspace access. Commit: 0a4b61d9c2e4 ("x86/amd_node: Fix AMD root device caching") re-ordered initialization so pci_request_config_region_exclusive() is called earlier and a failure exits amd_smn_init() before allocating 'amd_roots'. The setting of 'smn_exclusive' moved to the end of amd_smn_init(), after 'amd_roots' is allocated. It became redundant and can be removed. Replace 'smn_exclusive' with directly checking 'amd_roots', to fix a potential NULL pointer dereference and to simplify the logic. [ bp: Reorg commit message, touchup comment. ] [ mingo: Rebase & further touchups. ]