All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: do not try to set xattr into ea_inode if value is empty
@ 2021-03-05 12:05 zhangyi (F)
  2021-03-11 15:47 ` Theodore Ts'o
  0 siblings, 1 reply; 3+ messages in thread
From: zhangyi (F) @ 2021-03-05 12:05 UTC (permalink / raw)
  To: linux-ext4; +Cc: tytso, jack, yi.zhang

Syzbot report a warning that ext4 may create an empty ea_inode if set
an empty extent attribute to a file on the file system which is no free
blocks left.

  WARNING: CPU: 6 PID: 10667 at fs/ext4/xattr.c:1640 ext4_xattr_set_entry+0x10f8/0x1114 fs/ext4/xattr.c:1640
  ...
  Call trace:
   ext4_xattr_set_entry+0x10f8/0x1114 fs/ext4/xattr.c:1640
   ext4_xattr_block_set+0x1d0/0x1b1c fs/ext4/xattr.c:1942
   ext4_xattr_set_handle+0x8a0/0xf1c fs/ext4/xattr.c:2390
   ext4_xattr_set+0x120/0x1f0 fs/ext4/xattr.c:2491
   ext4_xattr_trusted_set+0x48/0x5c fs/ext4/xattr_trusted.c:37
   __vfs_setxattr+0x208/0x23c fs/xattr.c:177
  ...

Now, ext4 try to store extent attribute into an external inode if
ext4_xattr_block_set() return -ENOSPC, but for the case of store an
empty extent attribute, store the extent entry into the extent
attribute block is enough. A simple reproduce below.

  fallocate test.img -l 1M
  mkfs.ext4 -F -b 2048 -O ea_inode test.img
  mount test.img /mnt
  dd if=/dev/zero of=/mnt/foo bs=2048 count=500
  setfattr -n "user.test" /mnt/foo

Reported-by: syzbot+98b881fdd8ebf45ab4ae@syzkaller.appspotmail.com
Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
---
 fs/ext4/xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 372208500f4e..6aef74f7c9ee 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -2400,7 +2400,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
 				 * external inode if possible.
 				 */
 				if (ext4_has_feature_ea_inode(inode->i_sb) &&
-				    !i.in_inode) {
+				    i.value_len && !i.in_inode) {
 					i.in_inode = 1;
 					goto retry_inode;
 				}
-- 
2.25.4


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

* Re: [PATCH] ext4: do not try to set xattr into ea_inode if value is empty
  2021-03-05 12:05 [PATCH] ext4: do not try to set xattr into ea_inode if value is empty zhangyi (F)
@ 2021-03-11 15:47 ` Theodore Ts'o
  2021-03-11 15:50   ` Theodore Ts'o
  0 siblings, 1 reply; 3+ messages in thread
From: Theodore Ts'o @ 2021-03-11 15:47 UTC (permalink / raw)
  To: zhangyi (F); +Cc: linux-ext4, jack

On Fri, Mar 05, 2021 at 08:05:08PM +0800, zhangyi (F) wrote:
> Syzbot report a warning that ext4 may create an empty ea_inode if set
> an empty extent attribute to a file on the file system which is no free
> blocks left.

I'll apply this, but can you tell us which syzbot warning this
addresses so we can mark the commit appropriately?

Many thanks!!

					- Ted

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

* Re: [PATCH] ext4: do not try to set xattr into ea_inode if value is empty
  2021-03-11 15:47 ` Theodore Ts'o
@ 2021-03-11 15:50   ` Theodore Ts'o
  0 siblings, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2021-03-11 15:50 UTC (permalink / raw)
  To: zhangyi (F); +Cc: linux-ext4, jack

On Thu, Mar 11, 2021 at 10:47:40AM -0500, Theodore Ts'o wrote:
> On Fri, Mar 05, 2021 at 08:05:08PM +0800, zhangyi (F) wrote:
> > Syzbot report a warning that ext4 may create an empty ea_inode if set
> > an empty extent attribute to a file on the file system which is no free
> > blocks left.
> 
> I'll apply this, but can you tell us which syzbot warning this
> addresses so we can mark the commit appropriately?

Never mind, I missed the Reported-by: which identified the syzbot report.

      	      	     	 	      - Ted

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

end of thread, other threads:[~2021-03-11 15:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-05 12:05 [PATCH] ext4: do not try to set xattr into ea_inode if value is empty zhangyi (F)
2021-03-11 15:47 ` Theodore Ts'o
2021-03-11 15:50   ` Theodore Ts'o

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.