xfs
[Top] [All Lists]

[PATCH] xfs_repair: Check for invalid ACL types

To: david@xxxxxxxxxxxxx, xfs@xxxxxxxxxxx
Subject: [PATCH] xfs_repair: Check for invalid ACL types
From: Andreas Gruenbacher <agruenba@xxxxxxxxxx>
Date: Tue, 27 Oct 2015 02:23:52 +0100
Cc: Andreas Gruenbacher <agruenba@xxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <20151026225520.GK8773@dastard>
References: <1445627828-14661-1-git-send-email-agruenba@xxxxxxxxxx> <1445627828-14661-5-git-send-email-agruenba@xxxxxxxxxx> <20151026225520.GK8773@dastard>
Filesystems with the richacl feature are not supposed to contain POSIX
ACLs, and filesystems without the richacl feature are not supposed to
contain richacls.  Fix by removing unexpected attributes.

Signed-off-by: Andreas Gruenbacher <agruenba@xxxxxxxxxx>
---
 repair/attr_repair.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/repair/attr_repair.c b/repair/attr_repair.c
index e7f03a8..8ded369 100644
--- a/repair/attr_repair.c
+++ b/repair/attr_repair.c
@@ -160,6 +160,8 @@ valuecheck(
        int             namelen,
        int             valuelen)
 {
+       const bool feature_richacl = xfs_sb_has_incompat_feature(&mp->m_sb,
+               XFS_SB_FEAT_INCOMPAT_RICHACL);
        /* for proper alignment issues, get the structs and memmove the values 
*/
        xfs_mac_label_t macl;
        void *valuep;
@@ -169,6 +171,13 @@ valuecheck(
             strncmp(namevalue, SGI_ACL_FILE, SGI_ACL_FILE_SIZE) == 0) ||
            (namelen == SGI_ACL_DEFAULT_SIZE &&
             strncmp(namevalue, SGI_ACL_DEFAULT, SGI_ACL_DEFAULT_SIZE) == 0)) {
+               if (feature_richacl) {
+                       do_warn(_("filesystem feature %s set "
+                                 "but attribute %.*s exists\n"),
+                               "richacl", namelen, namevalue);
+                       return 1;
+               }
+
                if (value == NULL) {
                        valuep = malloc(valuelen);
                        if (!valuep)
@@ -211,6 +220,13 @@ valuecheck(
                 strncmp(namevalue, XATTR_RICHACL, strlen(XATTR_RICHACL)) == 0) 
{
                struct richacl *acl;
 
+               if (!feature_richacl) {
+                       do_warn(_("filesystem feature %s not set "
+                                 "but attribute %.*s exists\n"),
+                               "richacl", namelen, namevalue);
+                       return 1;
+               }
+
                if (value == NULL) {
                        valuep = malloc(valuelen);
                        if (!valuep)
-- 
2.5.0

<Prev in Thread] Current Thread [Next in Thread>