linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chao Yu <yuchao0@huawei.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Chao Yu <chao@kernel.org>,
	<linux-f2fs-devel@lists.sourceforge.net>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] f2fs: fix to check inline_xattr_size boundary correctly
Date: Wed, 13 Mar 2019 10:14:00 +0800	[thread overview]
Message-ID: <693a47aa-0bda-b910-bc83-d100e7c850c6@huawei.com> (raw)
In-Reply-To: <20190313020322.GA83715@jaegeuk-macbookpro.roam.corp.google.com>

On 2019/3/13 10:03, Jaegeuk Kim wrote:
> On 03/13, Chao Yu wrote:
>> On 2019/3/13 2:50, Jaegeuk Kim wrote:
>>> On 03/04, Chao Yu wrote:
>>>> Hi Jaegeuk,
>>>>
>>>> On 2019/2/15 0:08, Chao Yu wrote:
>>>>> ---
>>>>> v2:
>>>>> - fix lower bound check, inline xattr size should be larger than
>>>>> xattr_header's size at least.
>>>>
>>>> ...
>>>>
>>>>> +		if (F2FS_OPTION(sbi).inline_xattr_size <
>>>>> +			sizeof(struct f2fs_xattr_header) / sizeof(__le32)
>>>>
>>>> No sure we should set this low bound as above... now I guess original
>>>> non-zero check is enough.
>>>>
>>>> How do you think of setting inline_xattr_size range as
>>>> (0, MAX_INLINE_XATTR_SIZE]?
>>>
>>> How about this?
>>
>> If you think it's necessary to check low bound with size of xattr header,
>> I'm also okay with that.
>>
>> And below diff looks good to me, could you please merge this into original one?
>>
>> Thanks,
> 
> I had to add this on top of branch.

No problem.

> 
>>From 70db5b04cbe19e5ae7e85ada2d3e82bcfdf90352 Mon Sep 17 00:00:00 2001
> From: Jaegeuk Kim <jaegeuk@kernel.org>
> Date: Tue, 12 Mar 2019 11:49:53 -0700
> Subject: [PATCH] f2fs: give some messages for inline_xattr_size
> 
> This patch adds some kernel messages when user sets wrong inline_xattr_size.
> 
> Fixes: 500e0b28ecd3 ("f2fs: fix to check inline_xattr_size boundary correctly")

But this commit id may change when Linus pull your merge request...

Thanks,

> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/super.c | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 42eb5c86330a..324938ec95f3 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -821,6 +821,8 @@ static int parse_options(struct super_block *sb, char *options)
>  	}
>  
>  	if (test_opt(sbi, INLINE_XATTR_SIZE)) {
> +		int min_size, max_size;
> +
>  		if (!f2fs_sb_has_extra_attr(sbi) ||
>  			!f2fs_sb_has_flexible_inline_xattr(sbi)) {
>  			f2fs_msg(sb, KERN_ERR,
> @@ -834,15 +836,18 @@ static int parse_options(struct super_block *sb, char *options)
>  					"set with inline_xattr option");
>  			return -EINVAL;
>  		}
> -		if (F2FS_OPTION(sbi).inline_xattr_size <
> -			sizeof(struct f2fs_xattr_header) / sizeof(__le32) ||
> -			F2FS_OPTION(sbi).inline_xattr_size >
> -			DEF_ADDRS_PER_INODE -
> +
> +		min_size = sizeof(struct f2fs_xattr_header) / sizeof(__le32);
> +		max_size = DEF_ADDRS_PER_INODE -
>  			F2FS_TOTAL_EXTRA_ATTR_SIZE / sizeof(__le32) -
>  			DEF_INLINE_RESERVED_SIZE -
> -			MIN_INLINE_DENTRY_SIZE / sizeof(__le32)) {
> +			MIN_INLINE_DENTRY_SIZE / sizeof(__le32);
> +
> +		if (F2FS_OPTION(sbi).inline_xattr_size < min_size ||
> +				F2FS_OPTION(sbi).inline_xattr_size > max_size) {
>  			f2fs_msg(sb, KERN_ERR,
> -					"inline xattr size is out of range");
> +				"inline xattr size is out of range: %d ~ %d",
> +				min_size, max_size);
>  			return -EINVAL;
>  		}
>  	}
> 


      reply	other threads:[~2019-03-13  2:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-14 16:08 [PATCH v2] f2fs: fix to check inline_xattr_size boundary correctly Chao Yu
2019-03-04  6:39 ` Chao Yu
2019-03-06  6:32   ` [f2fs-dev] " Chao Yu
2019-03-12 18:50   ` Jaegeuk Kim
2019-03-13  1:23     ` Chao Yu
2019-03-13  2:03       ` Jaegeuk Kim
2019-03-13  2:14         ` Chao Yu [this message]

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=693a47aa-0bda-b910-bc83-d100e7c850c6@huawei.com \
    --to=yuchao0@huawei.com \
    --cc=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /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).