2023-11-15 11:19:58

by Luis Henriques

[permalink] [raw]
Subject: Re: [PATCH] ceph: quota: Fix invalid pointer access in

Wenchao Hao <[email protected]> writes:

> This issue is reported by smatch, get_quota_realm() might return
> ERR_PTR, so we should using IS_ERR_OR_NULL here to check the return
> value.
>
> Signed-off-by: Wenchao Hao <[email protected]>
> ---
> fs/ceph/quota.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ceph/quota.c b/fs/ceph/quota.c
> index 9d36c3532de1..c4b2929c6a83 100644
> --- a/fs/ceph/quota.c
> +++ b/fs/ceph/quota.c
> @@ -495,7 +495,7 @@ bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf)
> realm = get_quota_realm(mdsc, d_inode(fsc->sb->s_root),
> QUOTA_GET_MAX_BYTES, true);
> up_read(&mdsc->snap_rwsem);
> - if (!realm)
> + if (IS_ERR_OR_NULL(realm))
> return false;
>
> spin_lock(&realm->inodes_with_caps_lock);
> --
>
> 2.32.0
>

This looks right to me, the issue was introduced by commit 0c44a8e0fc55
("ceph: quota: fix quota subdir mounts"). FWIW:

Reviewed-by: Luis Henriques <[email protected]>

Cheers,
--
Luís


2023-11-15 11:25:35

by Xiubo Li

[permalink] [raw]
Subject: Re: [PATCH] ceph: quota: Fix invalid pointer access in


On 11/15/23 19:19, Luis Henriques wrote:
> Wenchao Hao <[email protected]> writes:
>
>> This issue is reported by smatch, get_quota_realm() might return
>> ERR_PTR, so we should using IS_ERR_OR_NULL here to check the return
>> value.
>>
>> Signed-off-by: Wenchao Hao <[email protected]>
>> ---
>> fs/ceph/quota.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/ceph/quota.c b/fs/ceph/quota.c
>> index 9d36c3532de1..c4b2929c6a83 100644
>> --- a/fs/ceph/quota.c
>> +++ b/fs/ceph/quota.c
>> @@ -495,7 +495,7 @@ bool ceph_quota_update_statfs(struct ceph_fs_client *fsc, struct kstatfs *buf)
>> realm = get_quota_realm(mdsc, d_inode(fsc->sb->s_root),
>> QUOTA_GET_MAX_BYTES, true);
>> up_read(&mdsc->snap_rwsem);
>> - if (!realm)
>> + if (IS_ERR_OR_NULL(realm))
>> return false;
>>
>> spin_lock(&realm->inodes_with_caps_lock);
>> --
>>
>> 2.32.0
>>
> This looks right to me, the issue was introduced by commit 0c44a8e0fc55
> ("ceph: quota: fix quota subdir mounts"). FWIW:
>
> Reviewed-by: Luis Henriques <[email protected]>

Thanks Luis. I have updated the testing branch.

- Xiubo


> Cheers,