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:
 <PUZPR04MB63160790974C70C70C8A062481F2A@PUZPR04MB6316.apcprd04.prod.outlook.com>
Date: Tue, 21 Oct 2025 01:38:29 +0000
From: "Yuezhang.Mo@...y.com" <Yuezhang.Mo@...y.com>
To: Shuhao Fu <sfual@....ust.hk>, Namjae Jeon <linkinjeon@...nel.org>,
        Sungjong Seo <sj1557.seo@...sung.com>
CC: "linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] exfat: fix refcount leak in exfat_find

On Mon, Oct 20, 2025 23:00 Shuhao Fu <sfual@....ust.hk> wrote:
> Fix refcount leaks in `exfat_find` related to `exfat_get_dentry_set`.
> 
> Function `exfat_get_dentry_set` would increase the reference counter of
> `es->bh` on success. Therefore, `exfat_put_dentry_set` must be called
> after `exfat_get_dentry_set` to ensure refcount consistency. In
> `exfat_find`, two branchs fail to call `exfat_put_dentry_set`, leading
> to possible resource leaks.
> 
> Fixes: 82ebecdc74ff ("exfat: fix improper check of dentry.stream.valid_size")
> Fixes: 13940cef9549 ("exfat: add a check for invalid data size")
> Signed-off-by: Shuhao Fu <sfual@....ust.hk>
> ---
>  fs/exfat/namei.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
> index 745dce29d..083a9d790 100644
> --- a/fs/exfat/namei.c
> +++ b/fs/exfat/namei.c
> @@ -646,11 +646,13 @@ static int exfat_find(struct inode *dir, const struct qstr *qname,
>         info->size = le64_to_cpu(ep2->dentry.stream.size);
> 
>         if (info->valid_size < 0) {
> +               exfat_put_dentry_set(&es, false);
>                 exfat_fs_error(sb, "data valid size is invalid(%lld)", info->valid_size);
>                 return -EIO;
>         }
> 
>         if (unlikely(EXFAT_B_TO_CLU_ROUND_UP(info->size, sbi) > sbi->used_clusters)) {
> +               exfat_put_dentry_set(&es, false);
>                 exfat_fs_error(sb, "data size is invalid(%lld)", info->size);
>                 return -EIO;
>         }

Thanks for your patch.

I think it would be better to move these checks after exfat_put_dentry_set().
Because the following check will correct ->valid_size and ->size.

        if (!is_valid_cluster(sbi, info->start_clu) && info->size) {
                exfat_warn(sb, "start_clu is invalid cluster(0x%x)",
                                info->start_clu);
                info->size = 0;
                info->valid_size = 0;
        }

> --
> 2.39.5 (Apple Git-154)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ