* @kobj: kobject for sysfs resources
* @kobj_added: @kobj has been added and needs freeing
* @enabled: the patch is enabled (but operation may be incomplete)
+ * @forced: was involved in a forced transition
* @finish: for waiting till it is safe to remove the patch module
*/
struct klp_patch {
struct kobject kobj;
bool kobj_added;
bool enabled;
+ bool forced;
struct completion finish;
};
*/
DEFINE_MUTEX(klp_mutex);
-static LIST_HEAD(klp_patches);
+/* Registered patches */
+LIST_HEAD(klp_patches);
static struct kobject *klp_root_kobj;
INIT_LIST_HEAD(&patch->list);
patch->kobj_added = false;
patch->enabled = false;
+ patch->forced = false;
init_completion(&patch->finish);
klp_for_each_object(patch, obj) {
#include <linux/livepatch.h>
extern struct mutex klp_mutex;
+extern struct list_head klp_patches;
static inline bool klp_is_object_loaded(struct klp_object *obj)
{
static int klp_target_state = KLP_UNDEFINED;
-static bool klp_forced = false;
-
/*
* This work can be performed periodically to finish patching or unpatching any
* "straggler" tasks which failed to transition in the first attempt.
klp_target_state == KLP_PATCHED ? "patching" : "unpatching");
/*
- * klp_forced set implies unbounded increase of module's ref count if
+ * patch->forced set implies unbounded increase of module's ref count if
* the module is disabled/enabled in a loop.
*/
- if (!klp_forced && klp_target_state == KLP_UNPATCHED)
+ if (!klp_transition_patch->forced && klp_target_state == KLP_UNPATCHED)
module_put(klp_transition_patch->mod);
klp_target_state = KLP_UNDEFINED;
*/
void klp_force_transition(void)
{
+ struct klp_patch *patch;
struct task_struct *g, *task;
unsigned int cpu;
for_each_possible_cpu(cpu)
klp_update_patch_state(idle_task(cpu));
- klp_forced = true;
+ list_for_each_entry(patch, &klp_patches, list)
+ patch->forced = true;
}