@@ -56,7 +56,26 @@ static int init_inode_xattrs(struct inode *inode)
56
56
return 0 ;
57
57
58
58
vi = EROFS_V (inode );
59
- BUG_ON (!vi -> xattr_isize );
59
+
60
+ /*
61
+ * bypass all xattr operations if ->xattr_isize is not greater than
62
+ * sizeof(struct erofs_xattr_ibody_header), in detail:
63
+ * 1) it is not enough to contain erofs_xattr_ibody_header then
64
+ * ->xattr_isize should be 0 (it means no xattr);
65
+ * 2) it is just to contain erofs_xattr_ibody_header, which is on-disk
66
+ * undefined right now (maybe use later with some new sb feature).
67
+ */
68
+ if (vi -> xattr_isize == sizeof (struct erofs_xattr_ibody_header )) {
69
+ errln ("xattr_isize %d of nid %llu is not supported yet" ,
70
+ vi -> xattr_isize , vi -> nid );
71
+ return - ENOTSUPP ;
72
+ } else if (vi -> xattr_isize < sizeof (struct erofs_xattr_ibody_header )) {
73
+ if (unlikely (vi -> xattr_isize )) {
74
+ DBG_BUGON (1 );
75
+ return - EIO ; /* xattr ondisk layout error */
76
+ }
77
+ return - ENOATTR ;
78
+ }
60
79
61
80
sb = inode -> i_sb ;
62
81
sbi = EROFS_SB (sb );
@@ -424,7 +443,6 @@ static int erofs_xattr_generic_get(const struct xattr_handler *handler,
424
443
struct dentry * unused , struct inode * inode ,
425
444
const char * name , void * buffer , size_t size )
426
445
{
427
- struct erofs_vnode * const vi = EROFS_V (inode );
428
446
struct erofs_sb_info * const sbi = EROFS_I_SB (inode );
429
447
430
448
switch (handler -> flags ) {
@@ -442,9 +460,6 @@ static int erofs_xattr_generic_get(const struct xattr_handler *handler,
442
460
return - EINVAL ;
443
461
}
444
462
445
- if (!vi -> xattr_isize )
446
- return - ENOATTR ;
447
-
448
463
return erofs_getxattr (inode , handler -> flags , name , buffer , size );
449
464
}
450
465
0 commit comments