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]
Message-ID: <alpine.LSU.2.21.1812031542540.22317@pobox.suse.cz>
Date:   Mon, 3 Dec 2018 15:59:57 +0100 (CET)
From:   Miroslav Benes <mbenes@...e.cz>
To:     Petr Mladek <pmladek@...e.com>
cc:     Jiri Kosina <jikos@...nel.org>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        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 03/11] livepatch: Consolidate klp_free functions

On Thu, 29 Nov 2018, Petr Mladek wrote:

> -static int klp_init_patch(struct klp_patch *patch)
> +/* Init operations that must succeed before klp_free_patch() can be called. */
> +static int klp_init_patch_before_free(struct klp_patch *patch)

There is no klp_free_patch() now, so the comment is not correct. Also I 
don't know if the function name is ideal, but I don't have a better one.

>  {
>  	struct klp_object *obj;
> -	int ret;
> +	struct klp_func *func;
>  
>  	if (!patch->objs)
>  		return -EINVAL;
>  
> -	mutex_lock(&klp_mutex);
> -
> +	INIT_LIST_HEAD(&patch->list);
> +	patch->kobj_alive = false;
>  	patch->enabled = false;
>  	init_completion(&patch->finish);
>  
> -	ret = kobject_init_and_add(&patch->kobj, &klp_ktype_patch,
> -				   klp_root_kobj, "%s", patch->mod->name);
> +	klp_for_each_object(patch, obj) {
> +		if (!obj->funcs)
> +			return -EINVAL;
> +
> +		obj->kobj_alive = false;
> +
> +		klp_for_each_func(obj, func)
> +			func->kobj_alive = false;
> +	}
> +
> +	return 0;
> +}
> +
> +static int klp_init_patch(struct klp_patch *patch)
> +{
> +	struct klp_object *obj;
> +	int ret;
> +
> +	mutex_lock(&klp_mutex);
> +
> +	ret = klp_init_patch_before_free(patch);
>  	if (ret) {
>  		mutex_unlock(&klp_mutex);
>  		return ret;
>  	}
>  
> +	ret = kobject_init_and_add(&patch->kobj, &klp_ktype_patch,
> +				   klp_root_kobj, "%s", patch->mod->name);
> +	if (ret)
> +		goto free;

Is this intentional? It should be sufficient (and it was before the patch) to
unlock the mutex and return ret. We do not need to free anything here. Only
klp_patch instance was initialized and that is all.

Otherwise it looks good. kobj_alive feels safer than state_initialized.

Thanks,
Miroslav

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ