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: <342f5e80-40a6-0fd3-7ac2-9b4dcd5461d6@huawei.com>
Date: Sun, 28 Sep 2025 09:54:51 +0800
From: yangerkun <yangerkun@...wei.com>
To: Li Chen <me@...ux.beauty>, Jens Axboe <axboe@...nel.dk>,
	<linux-block@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] loop: fix backing file reference leak on validation error



在 2025/9/26 20:12, Li Chen 写道:
> loop_change_fd() and loop_configure() call loop_check_backing_file()
> to validate the new backing file. If validation fails, the reference
> acquired by fget() was not dropped, leaking a file reference.
> 
> Fix this by calling fput(file) before returning the error.
> 
> Signed-off-by: Li Chen <chenl311@...natelecom.cn>

You'd better add a fix tag:

Fixes: f5c84eff634b ("loop: Add sanity check for read/write_iter")

Or this patch looks good to me.

Reviewed-by: Yang Erkun <yangerkun@...wei.com>

> ---
>   drivers/block/loop.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index 053a086d547e..94ec7f747f36 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -551,8 +551,10 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
>   		return -EBADF;
>   
>   	error = loop_check_backing_file(file);
> -	if (error)
> +	if (error) {
> +		fput(file);
>   		return error;
> +	}
>   
>   	/* suppress uevents while reconfiguring the device */
>   	dev_set_uevent_suppress(disk_to_dev(lo->lo_disk), 1);
> @@ -993,8 +995,10 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode,
>   		return -EBADF;
>   
>   	error = loop_check_backing_file(file);
> -	if (error)
> +	if (error) {
> +		fput(file);
>   		return error;
> +	}
>   
>   	is_loop = is_loop_device(file);
>   

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ