суббота

[Bug 2190887] Re: Forcing one livepatch transition leaves every other livepatch module unremovable (missing upstream 2957308343fa)

** Tags added: kernel-daily-bug -- You received this bug notification because you are subscribed to linux in Ubuntu. Matching subscriptions: Bgg, Bmail, Nb https://bugs.launchpad.net/bugs/2190887 Title: Forcing one livepatch transition leaves every other livepatch module unremovable (missing upstream 2957308343fa) Status in linux package in Ubuntu: New Bug description: [ Impact ] On the jammy 5.15 kernel, writing 1 to /sys/kernel/livepatch/<patch>/force marks every live patch on the list as forced, not only the patches being removed. The kernel never drops the module reference of a forced patch, so the module of a live patch that is later disabled through a normal transition cannot be removed until reboot. After an administrator forces one stuck transition, no other live patch module on the system can be unloaded. Mainline fixed this in v5.18 with commit 2957308343fa ("livepatch: Don't block removal of patches that are safe to unload"). The 5.15.y stable series never took it and ended with 5.15.227 on 1 December 2026, so it will not arrive through stable updates. Ubuntu-5.15.0-204.214 still sets the flag on every patch in klp_force_transition(). [ Fix ] Clean cherry-pick of the upstream commit (applies to Ubuntu-5.15.0-204.214 at an offset of 14 lines, no fuzz): 2957308343fa livepatch: Don't block removal of patches that are safe to unload It changes only klp_force_transition() in kernel/livepatch/transition.c. The forced flag is set on the transition patch when a transition to the unpatched state is forced, and on the replaced patches when a forced transition applies an atomic-replace patch. No later mainline commit names it in a Fixes: tag. [ Test Plan ] With the kernel's livepatch test modules (lib/livepatch in v5.15) built for the running kernel: 1. insmod test_klp_livepatch.ko and wait until /sys/kernel/livepatch/test_klp_livepatch/transition reads 0. 2. insmod test_klp_callbacks_busy.ko block_transition=1, then insmod test_klp_callbacks_demo.ko. Its transition stays at 1 because the busy worker sleeps in a function the patch replaces. 3. echo 1 > /sys/kernel/livepatch/test_klp_callbacks_demo/force and wait until its transition reads 0. 4. echo 0 > /sys/kernel/livepatch/test_klp_livepatch/enabled and wait until the directory is gone. 5. rmmod test_klp_livepatch On 5.15.0-204-generic step 5 fails. After step 4, /sys/module/test_klp_livepatch/refcnt reads 1 and rmmod reports "rmmod: ERROR: Module test_klp_livepatch is in use". On noble 6.8.0-147-generic, which has the commit, the same steps leave refcnt 0 and rmmod removes the module. With the fix, step 5 is expected to remove the module, as it does on noble. To clean up, write 0 to /sys/module/test_klp_callbacks_busy/parameters/block_transition. On 5.15 the forced test_klp_callbacks_demo also stays loaded until reboot, because the same loop marks it forced (kernel/livepatch/transition.c at v5.15, lines 643-644); with the fix, a patch forced forward is not marked, so it can be disabled and removed afterwards. [ Where problems could occur ] The change matters only where an administrator forces a livepatch transition. Patches that are not being removed keep normal module reference counting afterwards, so their modules can be unloaded once they are disabled. If the new condition missed a patch whose code can still run after a forced transition, that patch's module could be unloaded while in use and the kernel could crash. The commit sets the flag on exactly the patches a forced transition leaves possibly still in use, and it has been in mainline since v5.18. [ Other Info ] Found while testing klp-watch, a read-only observer of livepatch transitions (https://github.com/kazuru-chidumbwe/klp-watch), on Ubuntu 22.04. Its test of a forced transition therefore runs as the last test of a fresh boot, to work around this. To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2190887/+subscriptions

Комментариев нет:

Отправить комментарий