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:   Fri, 5 May 2023 19:32:34 +0300
From:   Leon Romanovsky <leon@...nel.org>
To:     ye.xingchen@....com.cn
Cc:     jgg@...pe.ca, jiangjian@...rlc.com, linux-rdma@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] RDMA/core: Use fdget() and fdput()

On Fri, May 05, 2023 at 11:33:57AM +0800, ye.xingchen@....com.cn wrote:
> From: Ye Xingchen <ye.xingchen@....com.cn>
> 
> convert the fget()/fput() uses to fdget()/fdput().

Why? What is wrong with current implementation?

Thanks

> 
> Signed-off-by: Ye Xingchen <ye.xingchen@....com.cn>
> ---
>  drivers/infiniband/core/rdma_core.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/infiniband/core/rdma_core.c b/drivers/infiniband/core/rdma_core.c
> index 29b1ab1d5f93..c35df0b27e86 100644
> --- a/drivers/infiniband/core/rdma_core.c
> +++ b/drivers/infiniband/core/rdma_core.c
> @@ -335,7 +335,7 @@ lookup_get_fd_uobject(const struct uverbs_api_object *obj,
>  		      enum rdma_lookup_mode mode)
>  {
>  	const struct uverbs_obj_fd_type *fd_type;
> -	struct file *f;
> +	struct fd f = fdget(fdno);
>  	struct ib_uobject *uobject;
>  	int fdno = id;
> 
> @@ -350,18 +350,17 @@ lookup_get_fd_uobject(const struct uverbs_api_object *obj,
>  	fd_type =
>  		container_of(obj->type_attrs, struct uverbs_obj_fd_type, type);
> 
> -	f = fget(fdno);
> -	if (!f)
> +	if (!f.file)
>  		return ERR_PTR(-EBADF);
> 
> -	uobject = f->private_data;
> +	uobject = f.file->private_data;
>  	/*
>  	 * fget(id) ensures we are not currently running
>  	 * uverbs_uobject_fd_release(), and the caller is expected to ensure
>  	 * that release is never done while a call to lookup is possible.
>  	 */
> -	if (f->f_op != fd_type->fops || uobject->ufile != ufile) {
> -		fput(f);
> +	if (f.file->f_op != fd_type->fops || uobject->ufile != ufile) {
> +		fdput(f);
>  		return ERR_PTR(-EBADF);
>  	}
> 
> -- 
> 2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ