linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: correct removexattr behavior for null valued extended attribute
       [not found] <CGME20180109002241epcas1p46c06112eb4a2beef7ca377cbfe3b6e33@epcas1p4.samsung.com>
@ 2018-01-09  0:22 ` Daeho Jeong
  2018-01-09  9:27   ` Chao Yu
       [not found]   ` <CGME20180109002241epcas1p46c06112eb4a2beef7ca377cbfe3b6e33@epcms1p2>
  0 siblings, 2 replies; 6+ messages in thread
From: Daeho Jeong @ 2018-01-09  0:22 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Youngjin Gil

__vfs_removexattr() transfers "NULL" value to the setxattr handler of
the f2fs filesystem in order to remove the extended attribute. But,
__f2fs_setxattr() just ignores the removal request when the value of
the extended attribute is already NULL. We have to remove the extended
attribute itself even if the value of that is already NULL.

Signed-off-by: Daeho Jeong <daeho.jeong@samsung.com>
Signed-off-by: Youngjin Gil <youngjin.gil@samsung.com>
Tested-by: Hobin Woo <hobin.woo@samsung.com>
---
 fs/f2fs/xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index ec8961e..2776618 100644
--- a/fs/f2fs/xattr.c
+++ b/fs/f2fs/xattr.c
@@ -598,7 +598,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
 			goto exit;
 		}
 
-		if (f2fs_xattr_value_same(here, value, size))
+		if (value && f2fs_xattr_value_same(here, value, size))
 			goto exit;
 	} else if ((flags & XATTR_REPLACE)) {
 		error = -ENODATA;
-- 
1.9.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] f2fs: correct removexattr behavior for null valued extended attribute
  2018-01-09  0:22 ` Daeho Jeong
@ 2018-01-09  9:27   ` Chao Yu
       [not found]   ` <CGME20180109002241epcas1p46c06112eb4a2beef7ca377cbfe3b6e33@epcms1p2>
  1 sibling, 0 replies; 6+ messages in thread
From: Chao Yu @ 2018-01-09  9:27 UTC (permalink / raw)
  To: Daeho Jeong, linux-f2fs-devel; +Cc: Youngjin Gil

On 2018/1/9 8:22, Daeho Jeong wrote:
> __vfs_removexattr() transfers "NULL" value to the setxattr handler of
> the f2fs filesystem in order to remove the extended attribute. But,
> __f2fs_setxattr() just ignores the removal request when the value of
> the extended attribute is already NULL. We have to remove the extended

How can we build such xattr entry whose value is NULL? Can you give an
reproducer example?

Thanks,

> attribute itself even if the value of that is already NULL.
> 
> Signed-off-by: Daeho Jeong <daeho.jeong@samsung.com>
> Signed-off-by: Youngjin Gil <youngjin.gil@samsung.com>
> Tested-by: Hobin Woo <hobin.woo@samsung.com>
> ---
>  fs/f2fs/xattr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
> index ec8961e..2776618 100644
> --- a/fs/f2fs/xattr.c
> +++ b/fs/f2fs/xattr.c
> @@ -598,7 +598,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
>  			goto exit;
>  		}
>  
> -		if (f2fs_xattr_value_same(here, value, size))
> +		if (value && f2fs_xattr_value_same(here, value, size))
>  			goto exit;
>  	} else if ((flags & XATTR_REPLACE)) {
>  		error = -ENODATA;
> 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] f2fs: correct removexattr behavior for null valued extended attribute
       [not found]   ` <CGME20180109002241epcas1p46c06112eb4a2beef7ca377cbfe3b6e33@epcms1p2>
@ 2018-01-09  9:59     ` Daeho Jeong
  2018-01-09 11:32       ` Chao Yu
  0 siblings, 1 reply; 6+ messages in thread
From: Daeho Jeong @ 2018-01-09  9:59 UTC (permalink / raw)
  To: linux-f2fs-devel@lists.sourceforge.net

Hi, Chao

> How can we build such xattr entry whose value is NULL? Can you give an
> reproducer example?
 
We used setxattr system call with "value" as NULL and "size" as 0.
And then vfs_setxattr will change "value" to "" and transfer "value" and "size"
to f2fs_setxattr().

Thanks,

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] f2fs: correct removexattr behavior for null valued extended attribute
  2018-01-09  9:59     ` Daeho Jeong
@ 2018-01-09 11:32       ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2018-01-09 11:32 UTC (permalink / raw)
  To: daeho.jeong, linux-f2fs-devel@lists.sourceforge.net

Hi Daeho,

On 2018/1/9 17:59, Daeho Jeong wrote:
> Hi, Chao
> 
>> How can we build such xattr entry whose value is NULL? Can you give an
>> reproducer example?
>  
> We used setxattr system call with "value" as NULL and "size" as 0.
> And then vfs_setxattr will change "value" to "" and transfer "value" and "size"
> to f2fs_setxattr().

Correct, I can reproduce this bug with:

1. touch file
2. setfattr -n "user.foo" file
3. setfattr -x "user.foo" file
4. getfattr -d file
user.foo

After applying your patch, the problem can be fixed.

Could you add below test case explicitly in your commit log?

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Tested-by: Chao Yu <yuchao0@huawei.com>

Thanks,

> 
> Thanks,
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
> 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] f2fs: correct removexattr behavior for null valued extended attribute
@ 2018-01-20  7:46 Chao Yu
  2018-01-20 22:04 ` Jaegeuk Kim
  0 siblings, 1 reply; 6+ messages in thread
From: Chao Yu @ 2018-01-20  7:46 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

From: Daeho Jeong <daeho.jeong@samsung.com>

__vfs_removexattr() transfers "NULL" value to the setxattr handler of
the f2fs filesystem in order to remove the extended attribute. But,
__f2fs_setxattr() just ignores the removal request when the value of
the extended attribute is already NULL. We have to remove the extended
attribute itself even if the value of that is already NULL.

We can reporduce this bug with the below:

1. touch file
2. setfattr -n "user.foo" file
3. setfattr -x "user.foo" file
4. getfattr -d file
> user.foo

Signed-off-by: Daeho Jeong <daeho.jeong@samsung.com>
Signed-off-by: Youngjin Gil <youngjin.gil@samsung.com>
Tested-by: Hobin Woo <hobin.woo@samsung.com>
Tested-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index 600162f4ddbf..ae2dfa709f5d 100644
--- a/fs/f2fs/xattr.c
+++ b/fs/f2fs/xattr.c
@@ -600,7 +600,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
 			goto exit;
 		}
 
-		if (f2fs_xattr_value_same(here, value, size))
+		if (value && f2fs_xattr_value_same(here, value, size))
 			goto exit;
 	} else if ((flags & XATTR_REPLACE)) {
 		error = -ENODATA;
-- 
2.14.1.145.gb3622a4ee


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] f2fs: correct removexattr behavior for null valued extended attribute
  2018-01-20  7:46 [PATCH] f2fs: correct removexattr behavior for null valued extended attribute Chao Yu
@ 2018-01-20 22:04 ` Jaegeuk Kim
  0 siblings, 0 replies; 6+ messages in thread
From: Jaegeuk Kim @ 2018-01-20 22:04 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel

Thanks,

On 01/20, Chao Yu wrote:
> From: Daeho Jeong <daeho.jeong@samsung.com>
> 
> __vfs_removexattr() transfers "NULL" value to the setxattr handler of
> the f2fs filesystem in order to remove the extended attribute. But,
> __f2fs_setxattr() just ignores the removal request when the value of
> the extended attribute is already NULL. We have to remove the extended
> attribute itself even if the value of that is already NULL.
> 
> We can reporduce this bug with the below:
> 
> 1. touch file
> 2. setfattr -n "user.foo" file
> 3. setfattr -x "user.foo" file
> 4. getfattr -d file
> > user.foo
> 
> Signed-off-by: Daeho Jeong <daeho.jeong@samsung.com>
> Signed-off-by: Youngjin Gil <youngjin.gil@samsung.com>
> Tested-by: Hobin Woo <hobin.woo@samsung.com>
> Tested-by: Chao Yu <yuchao0@huawei.com>
> Reviewed-by: Chao Yu <yuchao0@huawei.com>
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> ---
>  fs/f2fs/xattr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
> index 600162f4ddbf..ae2dfa709f5d 100644
> --- a/fs/f2fs/xattr.c
> +++ b/fs/f2fs/xattr.c
> @@ -600,7 +600,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
>  			goto exit;
>  		}
>  
> -		if (f2fs_xattr_value_same(here, value, size))
> +		if (value && f2fs_xattr_value_same(here, value, size))
>  			goto exit;
>  	} else if ((flags & XATTR_REPLACE)) {
>  		error = -ENODATA;
> -- 
> 2.14.1.145.gb3622a4ee

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-01-20 22:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-20  7:46 [PATCH] f2fs: correct removexattr behavior for null valued extended attribute Chao Yu
2018-01-20 22:04 ` Jaegeuk Kim
     [not found] <CGME20180109002241epcas1p46c06112eb4a2beef7ca377cbfe3b6e33@epcas1p4.samsung.com>
2018-01-09  0:22 ` Daeho Jeong
2018-01-09  9:27   ` Chao Yu
     [not found]   ` <CGME20180109002241epcas1p46c06112eb4a2beef7ca377cbfe3b6e33@epcms1p2>
2018-01-09  9:59     ` Daeho Jeong
2018-01-09 11:32       ` Chao Yu

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).