All of lore.kernel.org
 help / color / mirror / Atom feed
From: "cgxu519@zoho.com.cn" <cgxu519@zoho.com.cn>
To: Jan Kara <jack@suse.cz>
Cc: jack@suse.com, linux-ext4@vger.kernel.org
Subject: Re: [PATCH] ext2: strengthen value length check in ext2_xattr_set()
Date: Wed, 22 May 2019 19:13:43 +0800	[thread overview]
Message-ID: <9777b34af1f4d3a79f8f6b1bdc1144e83d737086.camel@zoho.com.cn> (raw)
In-Reply-To: <20190522095057.GH17019@quack2.suse.cz>

On Wed, 2019-05-22 at 11:50 +0200, Jan Kara wrote:
> On Wed 22-05-19 16:28:46, Chengguang Xu wrote:
> > Actually maximum length of a valid entry value is not
> > ->s_blocksize because header, last entry and entry
> > name will also occupy some spaces. This patch
> > strengthens the value length check and return -ERANGE
> > when the length is larger than allowed maximum length.
> > 
> > Signed-off-by: Chengguang Xu <cgxu519@zoho.com.cn>
> 
> Thanks for the patch! But what's the point of this change? We would return
> ERANGE instead of ENOSPC? I don't think that's serious enough to warrant
> changing existing behavior...

Hi Jan,

Thanks for the review. 

The motivation is seprating error situations of ENOSPC/ERANGE
because ENOSPC is giving a hint that we can save an EA entry
(name+value > allowed maximum length) by deleting some existing
entries. However, as you has pointed out, I also think the
difference is not so important because some EA entries
(like security index) is invisible for user...

Thanks,
Chengguang


> 
> > @@ -423,7 +423,10 @@ ext2_xattr_set(struct inode *inode, int name_index,
> > const char *name,
> >  	if (name == NULL)
> >  		return -EINVAL;
> >  	name_len = strlen(name);
> > -	if (name_len > 255 || value_len > sb->s_blocksize)
> > +	max_len = sb->s_blocksize - sizeof(struct ext2_xattr_header)
> > +			- sizeof(__u32);
> > +	if (name_len > 255 ||
> > +	    EXT2_XATTR_LEN(name_len) + EXT2_XATTR_SIZE(value_len) > max_len)
> >  		return -ERANGE;
> >  	down_write(&EXT2_I(inode)->xattr_sem);
> >  	if (EXT2_I(inode)->i_file_acl) {
> 
> 								Honza
> 




  reply	other threads:[~2019-05-22 11:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22  8:28 [PATCH] ext2: strengthen value length check in ext2_xattr_set() Chengguang Xu
2019-05-22  9:50 ` Jan Kara
2019-05-22 11:13   ` cgxu519 [this message]
2019-05-24  6:11   ` cgxu519
2019-05-24  8:33     ` 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=9777b34af1f4d3a79f8f6b1bdc1144e83d737086.camel@zoho.com.cn \
    --to=cgxu519@zoho.com.cn \
    --cc=jack@suse.com \
    --cc=jack@suse.cz \
    --cc=linux-ext4@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.