Skip to content

kpatch script: better support for livepatch consistency model #751

@jpoimboe

Description

@jpoimboe

The kpatch script could use better support for livepatch modules. Some ideas below, roughly in descending order of usefulness.

  1. signaling stalled tasks: I'm thinking this should be automatically done by "kpatch load" if the patch transition hasn't completed within a reasonable amount of time (10 seconds?). Basically, after loading, I think it should poll the transition state, and not exit the script until the transition is complete. Then if it's still not done after n seconds, it should do something like:
for s in /proc/*/task/*/patch_state; do
        pid=$(echo $s | sed 's;/.*task/\(.*\)/patch_state;\1;')
        if [[ $(cat /proc/$pid/patch_state) = 0 ]]; then
                echo "signaling pid $j $(cat /proc/$j/comm)"
                kill -SIGSTOP $j
                kill -SIGCONT $j
        fi
done

NOTE: Miroslav is working on an official way to do the above with a single write to sysfs.

  1. reverting stalled patches: even if after signaling all the straggler tasks, the patch still fails to finish, I'm thinking "kpatch load" should reverse the patching process, unload the patch, and report an error.

  2. EDIT: NEVER MIND. We could even mark patches with a "force" modinfo attribute which the kpatch script could read, for patches which are safe to force but might otherwise get stuck in transition because they patch a commonly slept on function (e.g., sys_poll). Then, in "kpatch load", it could force the patch - either immediately, or after the timeout described in update README with new OVERVIEW and DEMONSTRATION section #1 above. This will need Miroslav's force patch.

  3. status of a transitioning patch: the "kpatch list" command should identify each patch as either "enabling...", "enabled", "disabling...", or "disabled". In the enabling/disabling case, it should list all the straggler tasks which are preventing the transition from completing.

  4. kpatch signal: a command for signaling straggler tasks.

  5. kpatch force: a command for forcing a patch as a last resort.

1-3 would be the "curated" approach -- just use "kpatch load"/"kpatch unload" and everything else is done for you. This will be used by most users, most of the time, to abstract away the details.

4-6 would be for those who want to load the module manually, without "kpatch load", in order to have more fine-grained control of the patching process.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions