lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 13 Dec 2018 16:55:28 -0600
From:   Josh Poimboeuf <jpoimboe@...hat.com>
To:     Petr Mladek <pmladek@...e.com>
Cc:     Jiri Kosina <jikos@...nel.org>, Miroslav Benes <mbenes@...e.cz>,
        Jason Baron <jbaron@...mai.com>,
        Joe Lawrence <joe.lawrence@...hat.com>,
        Evgenii Shatokhin <eshatokhin@...tuozzo.com>,
        live-patching@...r.kernel.org, linux-kernel@...r.kernel.org,
        Jessica Yu <jeyu@...nel.org>
Subject: Re: [PATCH v14 07/11] livepatch: Add atomic replace

On Thu, Nov 29, 2018 at 10:44:27AM +0100, Petr Mladek wrote:
> @@ -146,6 +150,7 @@ struct klp_object {
>   * struct klp_patch - patch structure for live patching
>   * @mod:	reference to the live patch module
>   * @objs:	object entries for kernel objects to be patched
> + * @replace:	replace all already registered patches

"all already registered" -> "all existing" ?

since we don't have a concept of "registered" patches anymore.

> @@ -415,6 +449,124 @@ static struct attribute *klp_patch_attrs[] = {
>  	NULL
>  };
>  
> +/*
> + * Dynamically allocated objects and functions.
> + */

I don't think this comment is needed.

> +static void klp_free_object_dynamic(struct klp_object *obj)
> +{
> +	kfree(obj->name);
> +	kfree(obj);
> +}
> @@ -456,6 +620,8 @@ static void klp_free_funcs(struct klp_object *obj)
>  		if (func->kobj_alive) {
>  			func->kobj_alive = false;
>  			kobject_put(&func->kobj);
> +		} else if (func->nop) {
> +			klp_free_func_nop(func);

This removes 'func' from the list, so it needs to do a 'safe' list
iteration.

>  		}
>  	}
>  }
> @@ -467,8 +633,12 @@ static void klp_free_object_loaded(struct klp_object *obj)
>  
>  	obj->mod = NULL;
>  
> -	klp_for_each_func(obj, func)
> +	klp_for_each_func(obj, func) {
>  		func->old_func = NULL;
> +
> +		if (func->nop)
> +			func->new_func = NULL;
> +	}
>  }
>  
>  static void klp_free_objects(struct klp_patch *patch)
> @@ -482,6 +652,8 @@ static void klp_free_objects(struct klp_patch *patch)
>  		if (obj->kobj_alive) {
>  			obj->kobj_alive = false;
>  			kobject_put(&obj->kobj);
> +		} else if (obj->dynamic) {
> +			klp_free_object_dynamic(obj);

Ditto.

> +void klp_discard_replaced_patches(struct klp_patch *new_patch)
> +{
> +	struct klp_patch *old_patch, *tmp_patch;
> +
> +	list_for_each_entry_safe(old_patch, tmp_patch, &klp_patches, list) {
> +		if (old_patch == new_patch)
> +			return;
> +
> +		old_patch->enabled = false;
> +		klp_unpatch_objects(old_patch);
> +		klp_free_patch_start(old_patch);
> +		schedule_work(&old_patch->free_work);
> +	}

This doesn't need the "safe" list iteration because it doesn't remove
the patch from the list.

Side note, it would probably be useful to have a klp_for_each_patch()
helper.

-- 
Josh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ