| @@ -70,6 +70,20 @@ static int ea_check_size(struct gfs2_sbd *sdp, unsigned int nsize, size_t dsize) · 69 unmodified lines |
| 70 | return 0; | 70 | return 0; |
| 71 | } | 71 | } |
| 72 | | 72 | |
| | 73 | static bool gfs2_eatype_valid(struct gfs2_sbd *sdp, u8 type) |
| | 74 | { |
| | 75 | switch(sdp->sd_sb.sb_fs_format) { |
| | 76 | case GFS2_FS_FORMAT_MAX: |
| | 77 | return true; |
| | 78 | |
| | 79 | case GFS2_FS_FORMAT_MIN: |
| | 80 | return type <= GFS2_EATYPE_SECURITY; |
| | 81 | |
| | 82 | default: |
| | 83 | return false; |
| | 84 | } |
| | 85 | } |
| | 86 | |
| 73 | typedef int (*ea_call_t) (struct gfs2_inode *ip, struct buffer_head *bh, | 87 | typedef int (*ea_call_t) (struct gfs2_inode *ip, struct buffer_head *bh, |
| 74 | struct gfs2_ea_header *ea, | 88 | struct gfs2_ea_header *ea, |
| 75 | struct gfs2_ea_header *prev, void *private); | 89 | struct gfs2_ea_header *prev, void *private); |
| @@ -77,6 +91,7 @@ typedef int (*ea_call_t) (struct gfs2_inode *ip, struct buffer_head *bh, · 1 unmodified line |
| 77 | static int ea_foreach_i(struct gfs2_inode *ip, struct buffer_head *bh, | 91 | static int ea_foreach_i(struct gfs2_inode *ip, struct buffer_head *bh, |
| 78 | ea_call_t ea_call, void *data) | 92 | ea_call_t ea_call, void *data) |
| 79 | { | 93 | { |
| | 94 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
| 80 | struct gfs2_ea_header *ea, *prev = NULL; | 95 | struct gfs2_ea_header *ea, *prev = NULL; |
| 81 | int error = 0; | 96 | int error = 0; |
| 82 | | 97 | |
| @@ -89,9 +104,8 @@ static int ea_foreach_i(struct gfs2_inode *ip, struct buffer_head *bh, · 6 unmodified lines |
| 89 | if (!(bh->b_data <= (char *)ea && (char *)GFS2_EA2NEXT(ea) <= | 104 | if (!(bh->b_data <= (char *)ea && (char *)GFS2_EA2NEXT(ea) <= |
| 90 | bh->b_data + bh->b_size)) | 105 | bh->b_data + bh->b_size)) |
| 91 | goto fail; | 106 | goto fail; |
| 92 | if (!GFS2_EATYPE_VALID(ea->ea_type)) | 107 | if (!gfs2_eatype_valid(sdp, ea->ea_type)) |
| 93 | goto fail; | 108 | goto fail; |
| 94 | | | |
| 95 | error = ea_call(ip, bh, ea, prev, data); | 109 | error = ea_call(ip, bh, ea, prev, data); |
| 96 | if (error) | 110 | if (error) |
| 97 | return error; | 111 | return error; |
| @@ -344,6 +358,7 @@ static int ea_list_i(struct gfs2_inode *ip, struct buffer_head *bh, · 246 unmodified lines |
| 344 | struct gfs2_ea_header *ea, struct gfs2_ea_header *prev, | 358 | struct gfs2_ea_header *ea, struct gfs2_ea_header *prev, |
| 345 | void *private) | 359 | void *private) |
| 346 | { | 360 | { |
| | 361 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
| 347 | struct ea_list *ei = private; | 362 | struct ea_list *ei = private; |
| 348 | struct gfs2_ea_request *er = ei->ei_er; | 363 | struct gfs2_ea_request *er = ei->ei_er; |
| 349 | unsigned int ea_size; | 364 | unsigned int ea_size; |
| @@ -353,6 +368,8 @@ static int ea_list_i(struct gfs2_inode *ip, struct buffer_head *bh, · 3 unmodified lines |
| 353 | if (ea->ea_type == GFS2_EATYPE_UNUSED) | 368 | if (ea->ea_type == GFS2_EATYPE_UNUSED) |
| 354 | return 0; | 369 | return 0; |
| 355 | | 370 | |
| | 371 | BUG_ON(ea->ea_type > GFS2_EATYPE_SECURITY && |
| | 372 | sdp->sd_sb.sb_fs_format == GFS2_FS_FORMAT_MIN); |
| 356 | switch (ea->ea_type) { | 373 | switch (ea->ea_type) { |
| 357 | case GFS2_EATYPE_USR: | 374 | case GFS2_EATYPE_USR: |
| 358 | prefix = "user."; | 375 | prefix = "user."; |
| @@ -366,8 +383,12 @@ static int ea_list_i(struct gfs2_inode *ip, struct buffer_head *bh, · 7 unmodified lines |
| 366 | prefix = "security."; | 383 | prefix = "security."; |
| 367 | l = 9; | 384 | l = 9; |
| 368 | break; | 385 | break; |
| | 386 | case GFS2_EATYPE_TRUSTED: |
| | 387 | prefix = "trusted."; |
| | 388 | l = 8; |
| | 389 | break; |
| 369 | default: | 390 | default: |
| 370 | BUG(); | 391 | return 0; |
| 371 | } | 392 | } |
| 372 | | 393 | |
| 373 | ea_size = l + ea->ea_name_len + 1; | 394 | ea_size = l + ea->ea_name_len + 1; |
| @@ -1463,7 +1484,25 @@ static const struct xattr_handler gfs2_xattr_security_handler = { · 1089 unmodified lines |
| 1463 | .set = gfs2_xattr_set, | 1484 | .set = gfs2_xattr_set, |
| 1464 | }; | 1485 | }; |
| 1465 | | 1486 | |
| 1466 | const struct xattr_handler *gfs2_xattr_handlers[] = { | 1487 | static bool |
| | 1488 | gfs2_xattr_trusted_list(struct dentry *dentry) |
| | 1489 | { |
| | 1490 | return capable(CAP_SYS_ADMIN); |
| | 1491 | } |
| | 1492 | |
| | 1493 | static const struct xattr_handler gfs2_xattr_trusted_handler = { |
| | 1494 | .prefix = XATTR_TRUSTED_PREFIX, |
| | 1495 | .flags = GFS2_EATYPE_TRUSTED, |
| | 1496 | .list = gfs2_xattr_trusted_list, |
| | 1497 | .get = gfs2_xattr_get, |
| | 1498 | .set = gfs2_xattr_set, |
| | 1499 | }; |
| | 1500 | |
| | 1501 | const struct xattr_handler *gfs2_xattr_handlers_max[] = { |
| | 1502 | /* GFS2_FS_FORMAT_MAX */ |
| | 1503 | &gfs2_xattr_trusted_handler, |
| | 1504 | |
| | 1505 | /* GFS2_FS_FORMAT_MIN */ |
| 1467 | &gfs2_xattr_user_handler, | 1506 | &gfs2_xattr_user_handler, |
| 1468 | &gfs2_xattr_security_handler, | 1507 | &gfs2_xattr_security_handler, |
| 1469 | &posix_acl_access_xattr_handler, | 1508 | &posix_acl_access_xattr_handler, |
| @@ -1471,3 +1510,4 @@ const struct xattr_handler *gfs2_xattr_handlers[] = { · 1 unmodified line |
| 1471 | NULL, | 1510 | NULL, |
| 1472 | }; | 1511 | }; |
| 1473 | | 1512 | |
| | 1513 | const struct xattr_handler **gfs2_xattr_handlers_min = gfs2_xattr_handlers_max + 1; |