[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-keyrings
Subject:    Re: [PATCH] keys/keyctl: Use kfree_rcu instead of kfree
From:       Jarkko Sakkinen <jarkko () kernel ! org>
Date:       2022-07-28 8:11:15
Message-ID: YuJEozyceOKQ63/6 () kernel ! org
[Download RAW message or body]

On Sat, Jul 23, 2022 at 07:20:35PM +0530, Siddh Raman Pant wrote:
> In keyctl_watch_key, use kfree_rcu() for freeing watch and wlist
> as they support RCU and have an rcu_head in the struct definition.
> 
> Signed-off-by: Siddh Raman Pant <code@siddh.me>

Applies to any patch: the commit message should *clearly* describe

1. What is wrong in the current code *behaviour*.
2. Why does the code change save the day.

> ---
>  security/keys/keyctl.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
> index 96a92a645216..087fbc141cfd 100644
> --- a/security/keys/keyctl.c
> +++ b/security/keys/keyctl.c
> @@ -1832,9 +1832,9 @@ long keyctl_watch_key(key_serial_t id, int watch_queue_fd, int watch_id)
>  	}
>  
>  err_watch:
> -	kfree(watch);
> +	kfree_rcu(watch, rcu);
>  err_wlist:
> -	kfree(wlist);
> +	kfree_rcu(wlist, rcu);
>  err_wqueue:
>  	put_watch_queue(wqueue);
>  err_key:
> -- 
> 2.35.1
> 
> 

BR, Jarkko
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic