@@ -55,7 +55,26 @@ static int init_inode_xattrs(struct inode *inode)
55
55
return 0 ;
56
56
57
57
vi = EROFS_V (inode );
58
- BUG_ON (!vi -> xattr_isize );
58
+
59
+ /*
60
+ * bypass all xattr operations if ->xattr_isize is not greater than
61
+ * sizeof(struct erofs_xattr_ibody_header), in detail:
62
+ * 1) it is not enough to contain erofs_xattr_ibody_header then
63
+ * ->xattr_isize should be 0 (it means no xattr);
64
+ * 2) it is just to contain erofs_xattr_ibody_header, which is on-disk
65
+ * undefined right now (maybe use later with some new sb feature).
66
+ */
67
+ if (vi -> xattr_isize == sizeof (struct erofs_xattr_ibody_header )) {
68
+ errln ("xattr_isize %d of nid %llu is not supported yet" ,
69
+ vi -> xattr_isize , vi -> nid );
70
+ return - ENOTSUPP ;
71
+ } else if (vi -> xattr_isize < sizeof (struct erofs_xattr_ibody_header )) {
72
+ if (unlikely (vi -> xattr_isize )) {
73
+ DBG_BUGON (1 );
74
+ return - EIO ; /* xattr ondisk layout error */
75
+ }
76
+ return - ENOATTR ;
77
+ }
59
78
60
79
sbi = EROFS_I_SB (inode );
61
80
it .blkaddr = erofs_blknr (iloc (sbi , vi -> nid ) + vi -> inode_isize );
@@ -414,7 +433,6 @@ static int erofs_xattr_generic_get(const struct xattr_handler *handler,
414
433
struct dentry * unused , struct inode * inode ,
415
434
const char * name , void * buffer , size_t size )
416
435
{
417
- struct erofs_vnode * const vi = EROFS_V (inode );
418
436
struct erofs_sb_info * const sbi = EROFS_I_SB (inode );
419
437
420
438
switch (handler -> flags ) {
@@ -432,9 +450,6 @@ static int erofs_xattr_generic_get(const struct xattr_handler *handler,
432
450
return - EINVAL ;
433
451
}
434
452
435
- if (!vi -> xattr_isize )
436
- return - ENOATTR ;
437
-
438
453
return erofs_getxattr (inode , handler -> flags , name , buffer , size );
439
454
}
440
455
0 commit comments