Merge tag 'docs-5.12' of git://git.lwn.net/linux
[linux-2.6-microblaze.git] / security / tomoyo / network.c
index f9ff121..478f757 100644 (file)
@@ -233,14 +233,14 @@ static bool tomoyo_merge_inet_acl(struct tomoyo_acl_info *a,
 {
        u8 * const a_perm =
                &container_of(a, struct tomoyo_inet_acl, head)->perm;
-       u8 perm = *a_perm;
+       u8 perm = READ_ONCE(*a_perm);
        const u8 b_perm = container_of(b, struct tomoyo_inet_acl, head)->perm;
 
        if (is_delete)
                perm &= ~b_perm;
        else
                perm |= b_perm;
-       *a_perm = perm;
+       WRITE_ONCE(*a_perm, perm);
        return !perm;
 }
 
@@ -259,14 +259,14 @@ static bool tomoyo_merge_unix_acl(struct tomoyo_acl_info *a,
 {
        u8 * const a_perm =
                &container_of(a, struct tomoyo_unix_acl, head)->perm;
-       u8 perm = *a_perm;
+       u8 perm = READ_ONCE(*a_perm);
        const u8 b_perm = container_of(b, struct tomoyo_unix_acl, head)->perm;
 
        if (is_delete)
                perm &= ~b_perm;
        else
                perm |= b_perm;
-       *a_perm = perm;
+       WRITE_ONCE(*a_perm, perm);
        return !perm;
 }
 
@@ -613,7 +613,7 @@ static int tomoyo_check_unix_address(struct sockaddr *addr,
 static bool tomoyo_kernel_service(void)
 {
        /* Nothing to do if I am a kernel service. */
-       return uaccess_kernel();
+       return (current->flags & (PF_KTHREAD | PF_IO_WORKER)) == PF_KTHREAD;
 }
 
 /**