public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kari Argillander <kari.argillander@gmail.com>
To: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>,
	joe@perches.com
Cc: ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v2 3/3] fs/ntfs3: Refactoring of ntfs_set_ea
Date: Mon, 27 Sep 2021 22:39:15 +0300	[thread overview]
Message-ID: <20210927193915.a6yexhkgfqt23bim@kari-VirtualBox> (raw)
In-Reply-To: <20210927192236.3s75h74aglrpg3s2@kari-VirtualBox>

Joe's address was wrong. Just resend.

On Mon, Sep 27, 2021 at 10:22:36PM +0300, Kari Argillander wrote:
> On Mon, Sep 27, 2021 at 06:28:37PM +0300, Konstantin Komarov wrote:
> > Make code more readable.
> > Don't try to read zero bytes.
> > Add warning when size of exteneded attribute exceeds limit.
> > Thanks Joe Perches <joe@perches.com> for help.
> 
> Usually if someone review and suggest something small do not add this
> kind of line to commit message. Also you need permission to add this. It
> us same kind of situation when we add suggested-by tag. Linux
> documentation stated that it cannot be there if we do not have
> permission from other.
> 
> Also at least add that person email 'to line'. Sometimes if someone make
> huge impact to patch you can ask and add this kind of line. But then
> again it might make more sense to add it suggested or even signed off
> tag depending in situation.
> 
> It can stay if Joe says it is ok.
> 
> > 
> > Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
> > ---
> >  fs/ntfs3/xattr.c | 31 +++++++++++++++++--------------
> >  1 file changed, 17 insertions(+), 14 deletions(-)
> > 
> > diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
> > index 1ab109723b10..5023d6f7e671 100644
> > --- a/fs/ntfs3/xattr.c
> > +++ b/fs/ntfs3/xattr.c
> > @@ -75,6 +75,7 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct EA_FULL **ea,
> >  			size_t add_bytes, const struct EA_INFO **info)
> >  {
> >  	int err;
> > +	struct ntfs_sb_info *sbi = ni->mi.sbi;
> >  	struct ATTR_LIST_ENTRY *le = NULL;
> >  	struct ATTRIB *attr_info, *attr_ea;
> >  	void *ea_p;
> > @@ -99,10 +100,10 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct EA_FULL **ea,
> >  
> >  	/* Check Ea limit. */
> >  	size = le32_to_cpu((*info)->size);
> > -	if (size > ni->mi.sbi->ea_max_size)
> > +	if (size > sbi->ea_max_size)
> >  		return -EFBIG;
> >  
> > -	if (attr_size(attr_ea) > ni->mi.sbi->ea_max_size)
> > +	if (attr_size(attr_ea) > sbi->ea_max_size)
> >  		return -EFBIG;
> >  
> >  	/* Allocate memory for packed Ea. */
> > @@ -110,15 +111,16 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct EA_FULL **ea,
> >  	if (!ea_p)
> >  		return -ENOMEM;
> >  
> > -	if (attr_ea->non_res) {
> > +	if (!size) {
> > +		;
> > +	} else if (attr_ea->non_res) {
> >  		struct runs_tree run;
> >  
> >  		run_init(&run);
> >  
> >  		err = attr_load_runs(attr_ea, ni, &run, NULL);
> >  		if (!err)
> > -			err = ntfs_read_run_nb(ni->mi.sbi, &run, 0, ea_p, size,
> > -					       NULL);
> > +			err = ntfs_read_run_nb(sbi, &run, 0, ea_p, size, NULL);
> >  		run_close(&run);
> >  
> >  		if (err)
> > @@ -366,21 +368,22 @@ static noinline int ntfs_set_ea(struct inode *inode, const char *name,
> >  	new_ea->name[name_len] = 0;
> >  	memcpy(new_ea->name + name_len + 1, value, val_size);
> >  	new_pack = le16_to_cpu(ea_info.size_pack) + packed_ea_size(new_ea);
> > -
> > -	/* Should fit into 16 bits. */
> > -	if (new_pack > 0xffff) {
> > -		err = -EFBIG; // -EINVAL?
> > -		goto out;
> > -	}
> >  	ea_info.size_pack = cpu_to_le16(new_pack);
> > -
> >  	/* New size of ATTR_EA. */
> >  	size += add;
> > -	if (size > sbi->ea_max_size) {
> > +	ea_info.size = cpu_to_le32(size);
> > +
> > +	/*
> > +	 * 1. Check ea_info.size_pack for overflow.
> > +	 * 2. New attibute size must fit value from $AttrDef
> > +	 */
> > +	if (new_pack > 0xffff || size > sbi->ea_max_size) {
> > +		ntfs_inode_warn(
> > +			inode,
> > +			"The size of extended attributes must not exceed 64KiB");
> >  		err = -EFBIG; // -EINVAL?
> >  		goto out;
> >  	}
> > -	ea_info.size = cpu_to_le32(size);
> >  
> >  update_ea:
> >  
> > -- 
> > 2.33.0
> > 
> > 

  reply	other threads:[~2021-09-27 19:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-27 15:26 [PATCH v2 0/3] fs/ntfs3: Refactoring of xattr.c Konstantin Komarov
2021-09-27 15:27 ` [PATCH v2 1/3] fs/ntfs3: Use available posix_acl_release instead of ntfs_posix_acl_release Konstantin Komarov
2021-09-27 15:28 ` [PATCH v2 2/3] fs/ntfs3: Remove locked argument in ntfs_set_ea Konstantin Komarov
2021-09-27 15:28 ` [PATCH v2 3/3] fs/ntfs3: Refactoring of ntfs_set_ea Konstantin Komarov
2021-09-27 19:22   ` Kari Argillander
2021-09-27 19:39     ` Kari Argillander [this message]
2021-09-27 19:02 ` [PATCH v2 0/3] fs/ntfs3: Refactoring of xattr.c Kari Argillander

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=20210927193915.a6yexhkgfqt23bim@kari-VirtualBox \
    --to=kari.argillander@gmail.com \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=joe@perches.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    /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