apparmor: update ctime whenever the mtime changes on an inode
authorJeff Layton <jlayton@kernel.org>
Wed, 5 Jul 2023 19:00:32 +0000 (15:00 -0400)
committerChristian Brauner <brauner@kernel.org>
Mon, 10 Jul 2023 08:04:52 +0000 (10:04 +0200)
In general, when updating the mtime on an inode, one must also update
the ctime. Add the missing ctime updates.

Acked-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Message-Id: <20230705190309.579783-5-jlayton@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
security/apparmor/apparmorfs.c
security/apparmor/policy_unpack.c

index db7a51acf9dbd40b52bc42e0c3312ccc29327512..c0605371883679ed94acc397052e2f696e2374b9 100644 (file)
@@ -1554,8 +1554,11 @@ void __aafs_profile_migrate_dents(struct aa_profile *old,
 
        for (i = 0; i < AAFS_PROF_SIZEOF; i++) {
                new->dents[i] = old->dents[i];
-               if (new->dents[i])
-                       new->dents[i]->d_inode->i_mtime = current_time(new->dents[i]->d_inode);
+               if (new->dents[i]) {
+                       struct inode *inode = d_inode(new->dents[i]);
+
+                       inode->i_mtime = inode->i_ctime = current_time(inode);
+               }
                old->dents[i] = NULL;
        }
 }
index 694fb7a099624b2e476bea0095d406f3db9b40fb..ed180722a8333b609a2393d2d6f059bdda804a80 100644 (file)
@@ -86,10 +86,13 @@ void __aa_loaddata_update(struct aa_loaddata *data, long revision)
 
        data->revision = revision;
        if ((data->dents[AAFS_LOADDATA_REVISION])) {
-               d_inode(data->dents[AAFS_LOADDATA_DIR])->i_mtime =
-                       current_time(d_inode(data->dents[AAFS_LOADDATA_DIR]));
-               d_inode(data->dents[AAFS_LOADDATA_REVISION])->i_mtime =
-                       current_time(d_inode(data->dents[AAFS_LOADDATA_REVISION]));
+               struct inode *inode;
+
+               inode = d_inode(data->dents[AAFS_LOADDATA_DIR]);
+               inode->i_mtime = inode->i_ctime = current_time(inode);
+
+               inode = d_inode(data->dents[AAFS_LOADDATA_REVISION]);
+               inode->i_mtime = inode->i_ctime = current_time(inode);
        }
 }