Skip to contentSkip to conversation

avc: remove unnecessary pointer reassignment

PATCH In review Jeff Vander Stoep 4 participants 5 messages Feb 26, 2015 – Mar 9, 2015 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 avc: remove unnecessary pointer reassignment

Commit f01e1af445fa ("selinux: don't pass in NULL avd to avc_has_perm_noaudit") made this pointer reassignment unnecessary. Avd should continue to reference the stack-based copy.

---
 security/selinux/avc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
security/selinux/avc.c +2 -4
index afcc0ae..3c17dda 100644
@@ -724,12 +724,10 @@ inline int avc_has_perm_noaudit(u32 ssid, u32 tsid,
 	rcu_read_lock();
 
 	node = avc_lookup(ssid, tsid, tclass);
-	if (unlikely(!node)) {
+	if (unlikely(!node))
 		node = avc_compute_av(ssid, tsid, tclass, avd);
-	} else {
+	else
 		memcpy(avd, &node->ae.avd, sizeof(*avd));
-		avd = &node->ae.avd;
-	}
 
 	denied = requested & ~(avd->allowed);
 	if (unlikely(denied))
Signature · 1 line
2.2.0.rc0.207.ga3a616c
Acked-by on v1 1/1
#1 lore raw
Quoted 36 lines · Jeff Vander Stoep

Commit f01e1af445fa ("selinux: don't pass in NULL avd to avc_has_perm_noaudit") made this pointer reassignment unnecessary. Avd should continue to reference the stack-based copy.

---
 security/selinux/avc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
security/selinux/avc.c +2 -5
index afcc0ae..3c17dda 100644
@@ -724,12 +724,10 @@ inline int avc_has_perm_noaudit(u32 ssid, u32 tsid,
        rcu_read_lock();
 
        node = avc_lookup(ssid, tsid, tclass);
-       if (unlikely(!node)) {
+       if (unlikely(!node))
                node = avc_compute_av(ssid, tsid, tclass, avd);
-       } else {
+       else
                memcpy(avd, &node->ae.avd, sizeof(*avd));
-               avd = &node->ae.avd;
-       }
 
        denied = requested & ~(avd->allowed);
        if (unlikely(denied))
--

2.2.0.rc0.207.ga3a616c

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].

Signature · 1 line
Nick Kralevich | Android Security | [email protected] | 650.214.4037
Acked-by on v1 1/1
#2 lore raw
In reply to Jeff Vander Stoep
Quoted 5 lines · Jeff Vander Stoep

Commit f01e1af445fa ("selinux: don't pass in NULL avd to avc_has_perm_noaudit") made this pointer reassignment unnecessary. Avd should continue to reference the stack-based copy.

Quoted 24 lines
---
 security/selinux/avc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
security/selinux/avc.c +2 -4
index afcc0ae..3c17dda 100644
@@ -724,12 +724,10 @@ inline int avc_has_perm_noaudit(u32 ssid, u32 tsid,
 	rcu_read_lock();
 
 	node = avc_lookup(ssid, tsid, tclass);
-	if (unlikely(!node)) {
+	if (unlikely(!node))
 		node = avc_compute_av(ssid, tsid, tclass, avd);
-	} else {
+	else
 		memcpy(avd, &node->ae.avd, sizeof(*avd));
-		avd = &node->ae.avd;
-	}
 
 	denied = requested & ~(avd->allowed);
 	if (unlikely(denied))
maintainer
#3 lore raw
Quoted 8 lines · Stephen Smalley
Quoted 5 lines · Jeff Vander Stoep

Commit f01e1af445fa ("selinux: don't pass in NULL avd to avc_has_perm_noaudit") made this pointer reassignment unnecessary. Avd should continue to reference the stack-based copy.

Thanks everyone for the patch and the review. I'll merge this next week into selinux#next.

Quoted 25 lines
Quoted 24 lines
---
 security/selinux/avc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
security/selinux/avc.c +2 -4
index afcc0ae..3c17dda 100644
@@ -724,12 +724,10 @@ inline int avc_has_perm_noaudit(u32 ssid, u32 tsid,
      rcu_read_lock();
 
      node = avc_lookup(ssid, tsid, tclass);
-     if (unlikely(!node)) {
+     if (unlikely(!node))
              node = avc_compute_av(ssid, tsid, tclass, avd);
-     } else {
+     else
              memcpy(avd, &node->ae.avd, sizeof(*avd));
-             avd = &node->ae.avd;
-     }
 
      denied = requested & ~(avd->allowed);
      if (unlikely(denied))
Signature · 2 lines
paul moore
www.paul-moore.com
maintainer
#4 lore raw
Quoted 6 lines · Paul Moore
Quoted 5 lines · Stephen Smalley
Quoted 4 lines · Jeff Vander Stoep

Commit f01e1af445fa ("selinux: don't pass in NULL avd to avc_has_perm_noaudit") made this pointer reassignment unnecessary. Avd should continue to reference the stack-based copy.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Thanks everyone for the patch and the review. I'll merge this next week into selinux#next.

I apologize for the delay, but I just merged this into selinux#next; it should be in the next linux-next kernel.

Signature · 2 lines
paul moore
www.paul-moore.com