[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<PUZPR04MB6316F58807941F86C2769FCC81F2A@PUZPR04MB6316.apcprd04.prod.outlook.com>
Date: Tue, 21 Oct 2025 08:21:57 +0000
From: "Yuezhang.Mo@...y.com" <Yuezhang.Mo@...y.com>
To: Shuhao Fu <sfual@....ust.hk>
CC: Namjae Jeon <linkinjeon@...nel.org>,
Sungjong Seo
<sj1557.seo@...sung.com>,
"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 Tue, Oct 21, 2025 16:04 Shuhao Fu <sfual@....ust.hk> wrote:
> On Tue, Oct 21, 2025 at 01:38:29AM +0000, Yuezhang.Mo@...y.com wrote:
> > On Mon, Oct 20, 2025 23:00 Shuhao Fu <sfual@....ust.hk> wrote:
> >
> > 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;
> > }
> >
>
> Do you mean that we should put these two checks after
> `exfat_put_dentry_set`, like below?
>
Yes, that's what I mean.
> @@ -645,18 +645,6 @@ static int exfat_find(struct inode *dir, const struct qstr *qname,
> info->valid_size = le64_to_cpu(ep2->dentry.stream.valid_size);
> info->size = le64_to_cpu(ep2->dentry.stream.size);
>
> - if (info->valid_size < 0) {
> - 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_fs_error(sb, "data size is invalid(%lld)", info->size);
> - return -EIO;
> - }
> -
> info->start_clu = le32_to_cpu(ep2->dentry.stream.start_clu);
> if (!is_valid_cluster(sbi, info->start_clu) && info->size) {
> exfat_warn(sb, "start_clu is invalid cluster(0x%x)",
> @@ -694,6 +682,16 @@ static int exfat_find(struct inode *dir, const struct qstr *qname,
> 0);
> exfat_put_dentry_set(&es, false);
>
> + if (info->valid_size < 0) {
> + 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_fs_error(sb, "data size is invalid(%lld)", info->size);
> + return -EIO;
> + }
> +
> if (ei->start_clu == EXFAT_FREE_CLUSTER) {
> exfat_fs_error(sb,
> "non-zero size file starts with zero cluster (size : %llu, p_dir : %u, entry : 0x%08x)",
>
> > > --
> > > 2.39.5 (Apple Git-154)
>
Powered by blists - more mailing lists