linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: Jan Kara <jack@suse.cz>
Cc: <jack@suse.com>, <tytso@mit.edu>, <brauner@kernel.org>,
	<linux-fsdevel@vger.kernel.org>, <linux-ext4@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <yukuai3@huawei.com>
Subject: Re: [PATCH v2 2/3] quota: Replace all block number checking with helper function
Date: Tue, 27 Sep 2022 09:07:36 +0800	[thread overview]
Message-ID: <5f5e3d09-7fc6-33e1-3f2e-669baf8e5da1@huawei.com> (raw)
In-Reply-To: <20220923114840.npx52cadeofesp5i@quack3>

在 2022/9/23 19:48, Jan Kara 写道:
> On Thu 22-09-22 21:04:00, Zhihao Cheng wrote:
>> Cleanup all block checking places, replace them with helper function
>> do_check_range().
>>
>> Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
>> ---
>>   fs/quota/quota_tree.c | 28 ++++++++++++----------------
>>   1 file changed, 12 insertions(+), 16 deletions(-)
> 
> Thanks for the fix! One comment below:
> 
>> diff --git a/fs/quota/quota_tree.c b/fs/quota/quota_tree.c
>> index f89186b6db1d..47711e739ddb 100644
>> --- a/fs/quota/quota_tree.c
>> +++ b/fs/quota/quota_tree.c
>> @@ -71,11 +71,12 @@ static ssize_t write_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf)
>>   	return ret;
>>   }
>>   
>> -static inline int do_check_range(struct super_block *sb, uint val, uint max_val)
>> +static inline int do_check_range(struct super_block *sb, uint val,
>> +				 uint min_val, uint max_val)
>>   {
>> -	if (val >= max_val) {
>> -		quota_error(sb, "Getting block too big (%u >= %u)",
>> -			    val, max_val);
>> +	if (val < min_val || val >= max_val) {
>> +		quota_error(sb, "Getting block %u out of range %u-%u",
>> +			    val, min_val, max_val);
>>   		return -EUCLEAN;
>>   	}
> 
> It is strange that do_check_range() checks min_val() with strict inequality
> and max_val with non-strict one. That's off-by-one problem waiting to
> happen when we forget about this detail. Probably make max_val
> non-inclusive as well (the parameter max_val suggests the passed value is
> the biggest valid one anyway).
> 
> 								Honza
> 

I have sent v3 series, see
https://lore.kernel.org/all/20220923134555.2623931-1-chengzhihao1@huawei.com/T/


  reply	other threads:[~2022-09-27  1:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22 13:03 [PATCH v2 0/3] Check content after reading from quota file Zhihao Cheng
2022-09-22 13:03 ` [PATCH v2 1/3] quota: Check next/prev free block number " Zhihao Cheng
2022-09-22 13:04 ` [PATCH v2 2/3] quota: Replace all block number checking with helper function Zhihao Cheng
2022-09-23 11:48   ` Jan Kara
2022-09-27  1:07     ` Zhihao Cheng [this message]
2022-09-22 13:04 ` [PATCH v2 3/3] quota: Add more checking after reading from quota file Zhihao Cheng
2022-09-23 11:44   ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5f5e3d09-7fc6-33e1-3f2e-669baf8e5da1@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.com \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=yukuai3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).