@@ -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 );
@@ -422,7 +441,6 @@ static int erofs_xattr_generic_get(const struct xattr_handler *handler,
422
441
struct dentry * unused , struct inode * inode ,
423
442
const char * name , void * buffer , size_t size )
424
443
{
425
- struct erofs_vnode * const vi = EROFS_V (inode );
426
444
struct erofs_sb_info * const sbi = EROFS_I_SB (inode );
427
445
428
446
switch (handler -> flags ) {
@@ -440,9 +458,6 @@ static int erofs_xattr_generic_get(const struct xattr_handler *handler,
440
458
return - EINVAL ;
441
459
}
442
460
443
- if (!vi -> xattr_isize )
444
- return - ENOATTR ;
445
-
446
461
return erofs_getxattr (inode , handler -> flags , name , buffer , size );
447
462
}
448
463
0 commit comments